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
Which Java and java.sql data types map to my specific database types?
What are 4 drivers available in JDBC? At what situation are four of the drivers used?
What is type 4 jdbc driver?
What is a merge field?
any one can explain about policy file rule? when i connect database with applet then ther is no compile time error but the run time error is occureed.i.e access is denied.policy file rule is related to this problem.
Name different methods for getting streams.
Differentiate between stored procedure and functions?
How does jdbc work?
Why do we use jdbc statements?
Why do we use jdbc in java?
Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?
What is the difference between executing, executequery, executeupdate in jdbc?
Why do we need jdbc driver?
How to connect html page to database using jdbc?
What is the advantage of namedparameterjdbctemplate?