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
List some new features available in jdbc 4.0?
What do you understand by jdbc datasource?
Write an sql to find all records having all numeric characters in a field ?
Explain the process of creating tables using NetBeans IDE?
What is @entity in java?
What is metadata in java programming?
What is odbc. how is it related to sql cli?
State the different connection methods used for creating different types of sql.
How do I know which jdbc driver to use?
How can I determine the isolation levels supported by my DBMS?
Is it possible to connect to multiple databases? Using single statement can we update or extract data from two or three or many databases?
Why hibernate is better than jdbc?
What are the three parts of a jdbc url?
How does a file store compare with a jdbc store?
What causes no suitable driver error?