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 are the jdbc api components?
What are the Isolation level in JDBC transaction?
What is the execute method in java?
Does jdbctemplate use prepared statements?
If you are given a choice to implement the code to either insert a record or update if already exist, which approach will you follow ?
Why do I have to reaccess the database for Array, Blob, and Clob data?
What does jdbc stand for?
How can you make the connection using jdbc?
What is 2-tier and 3-tier architecture?
What is url in jdbc connection?
What is jdbc drivers in java?
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?