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 the meaning of connection?
How do I start debugging problems related to the JDBC API?
What is jdbc in dbms?
What is jdbc architecture?
How can I determine where a given table is referenced via foreign keys?
What do you understand by DDL and DML statements?
What is jdbc and jdbc drivers?
How to make updates to updatable result sets in jdbc?
What is a JDBC 2.0 DataSource?
How many types of jdbc drivers are available?
What is a jdbc connection string?
What are the different types of lockings in jdbc?
How to check jdbc driver version in sql server?
What is jdbc odbc connection?
What are the differences between execute, executequery, and executeupdate?