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 |
Explain in detail about JDBC and its general features?
Is possible to open a connection to a database with exclusive mode with JDBC?
what are the drawbacks of JDBC? explain briefly?
Explain the necessary steps to connect to the database in java?
What is the difference between execute, executeQuery, executeUpdate?
How to insert an image or raw data into database?
What is drivermanager in java?
How to handle when the database crashes while reading the data from the database?
What is statement and resultset in jdbc?
how many JDBC drivers ?name them?
Which type of driver is unique in jdbc?
Which is better odbc or jdbc?