How to find total column from a resultset?

Answers were Sorted based on User's Feedback



How to find total column from a resultset?..

Answer / manik chand

resultSet.getMetaData().getColumnCount().

Is This Answer Correct ?    8 Yes 0 No

How to find total column from a resultset?..

Answer / shankar

int columnCnt = java.sql.ResultSetMetaData.getColumnCount();

Is This Answer Correct ?    7 Yes 1 No

How to find total column from a resultset?..

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

How to find total column from a resultset?..

Answer / tathagata

First one is the correct ans.2nd & 3rd will be return
toatal no rows not column.

Is This Answer Correct ?    0 Yes 1 No

How to find total column from a resultset?..

Answer / thiyagu

rs.getRow();

Is This Answer Correct ?    1 Yes 6 No

How to find total column from a resultset?..

Answer / ramu

while(rs.next())
{
getInt(1);
}

Is This Answer Correct ?    0 Yes 7 No

Post New Answer

More JDBC Interview Questions

What is JDBC Batch Processing and what are it’s benefits?

0 Answers  


Explain the process of creating tables using NetBeans IDE?

0 Answers  


What are the new features added to JDBC 4.0?

0 Answers  


Does sql allow null values ? Can we use it within where clause ?

0 Answers  


How a database driver can be loaded with jdbc 4.0 / java 6?

0 Answers  






What packages are used by jdbc?

0 Answers  


How can I write to the log used by DriverManager and JDBC drivers?

0 Answers  


Explain the main method?

0 Answers  


What is jsp and jdbc?

0 Answers  


how do we get the connection from connection pool

1 Answers  


How many ways can you update a result set?

0 Answers  


Give an example for execution of sql statement.

0 Answers  


Categories