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 the use of callablestatement? Name the method, which is used to prepare a callablestatement.

0 Answers  


How to set the attribute concurrency in resultset?

0 Answers  


What port does jdbc use?

0 Answers  


What does the jdbc connection interface?

0 Answers  


What is addbatch jdbc?

0 Answers  


How do I find ojdbc jar version?

0 Answers  


Is java a database?

0 Answers  


What are statements in JAVA ?

1 Answers   CTS,


can we define indexes on a foreign key? Explain pros and cons?

1 Answers  


any one can explain about policy file rule? when i connect database with applet then ther is no compile time error but the run time error is occureed.i.e access is denied.policy file rule is related to this problem.

0 Answers  


What are the different types of drivers under jdbc?

0 Answers  


What do you understand by jdbc driver and explain its types?

0 Answers  


Categories