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
Explain Basic Steps in Writing a Java Program Using Jdbc?
What are the steps required to execute a query in jdbc?
Expalin the method of calling a stored procedure from jdbc.
Is java a database?
Is uri the same as url?
What is jdbc connection string?
What are the common jdbc exceptions?
What is xe in oracle jdbc url?
What is the role of class.forname while loading drivers?
I have the choice of manipulating database data using a byte[] or a java.sql.blob. Which has best performance?
What are the different types of lockings in jdbc?
What is drivermanager in jdbc?
What are the new features added to JDBC 4.0?
What are jdbc?
Which of the attributes in the monitoring tab for a jdbc connection pool in the administrative console tell us how many clients are currently waiting for a connection?