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 oracle thin?
What is the difference between execute, executeQuery, executeUpdate?
Why is jdbc used?
What's the benefit for specifying constraints like not null, primary key explicitly instead of specifying it against the column ?
What is a connection string used for?
Explain some new features available in jdbc 4.0?
What is device controller?
Is jdbc an api?
What is the advantage of namedparameterjdbctemplate?
What is jdbc template?
What are the utilities of the callablestatement?
If iam using JDBC API, do I also have to use ODBC?