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 getconnection method in java?

0 Answers  


What is <discriminator > in Hibernate? How exactly inheritance of Object to Tables can be done? What is the benefits of discriminator?

1 Answers   AppLabs,


How can I manage special characters when I execute an insert query?

0 Answers  


What is the difference between jdbc and odbc?

0 Answers  


How do I retrieve a whole row of data at once, instead of calling an individual ResultSet.getXXX method for each column?

0 Answers  






How can we retrieve data from the resultset?

0 Answers  


What is the benefit of having jdbcrowset implementation?

0 Answers  


Give a way to check that all result sets have bin accessed and update counts are generated by execute method.

0 Answers  


Is it possible to connect to multiple databases? Using single statement can we update or extract data from two or three or many databases?

0 Answers  


What protocol does jdbc use?

0 Answers  


What are drivers available?

0 Answers  


DB2 Universal claims to support JDBC 2.0, But I can only get JDBC 1.0 functionality. What can I do?

0 Answers  


Categories