Answer Posted / rajshri
import java.sql.*;
class columncount
{
public static void main(String[]args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection
("jdbc:odbc:mydsnname");
Statement st=con.createStatement();
String sql="select * from table_name";
ResultSet rs=st.executeQuery(sql);
ResultSetMetaData rd=rs.getMetaData();
int k=rd.getColumnCount();
System.out.println("no of count is " +k);
}
catch(SQLException e1)
{
System.out.println("not working");
}
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
What is drivermanager in jdbc?
How do I load a database driver with JDBC 4.0 / Java 6?
How can I use the JDBC API to access a desktop database like Microsoft Access over the network?
Why would you use setautocommit(false) in jdbc?
Why “no suitable driver” error occurs?
Is jdbc a protocol?
What is database deadlock ? How can we avoid them?
What is difference between odbc and jdbc?
What are the flow statements of jdbc?
Describe the steps needed to execute a sql query using jdbc.
What is the function of drivermanager class?
How do I know which jdbc driver to use?
Why is jdbc needed?
Is odbc an api?
What types of DataSource objects are specified in the Optional Package?