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 |
Why do we use jdbc statements?
what is meant by connection pooling?
What is namedparameterjdbctemplate?
What is a merge field?
What is JDBC and ODBC and what are the differences between them?
11 Answers Idbi Bank, Infosys, Infoview, TCS,
What is the full form of jdbc and what is its purpose?
What do you understand by jdbc driver and explain its types?
What are the advantages of collection pools?
What is jdbc in dbms?
What is a lock in jdbc?
How we store procedure in oralce for callable statements in jdbc
What does executeupdate return in java?