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 difference between jdbc and odbc?
What are the packages are used in jdbc?
What does the jdbc resultset interface?
How can we execute stored procedures using callablestatement?
Why should we close database connections in java?
What is JDBC DataSource and what are it’s benefits?
Explain the steps in writing a java program using jdbc?
What is 2 phase commit?
Which Java and java.sql data types map to my specific database types?
What is meant by dao?
How MS-Access DB can be accessed over a network, using JDBC API?
please tell me the name and url path for type-4 driver ?
Is jdbc a web technology?
java based application for hospital management
What is an encrypted internet connection?