How to find total column from a resultset?
Answers were Sorted based on User's Feedback
Answer / shankar
int columnCnt = java.sql.ResultSetMetaData.getColumnCount();
Is This Answer Correct ? | 7 Yes | 1 No |
Answer / 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 |
What is JDBC Batch Processing and what are it’s benefits?
Explain the process of creating tables using NetBeans IDE?
What are the new features added to JDBC 4.0?
Does sql allow null values ? Can we use it within where clause ?
How a database driver can be loaded with jdbc 4.0 / java 6?
What packages are used by jdbc?
How can I write to the log used by DriverManager and JDBC drivers?
Explain the main method?
What is jsp and jdbc?
how do we get the connection from connection pool
How many ways can you update a result set?
Give an example for execution of sql statement.