How to find the column count in resultset?



How to find the column count in resultset?..

Answer / babu h m

We need to use MetaData option on the ResultSet in order to
get the column count

ResultSet xSet = stmt.executeQuery() ;
ResultSetMetaData rsMetaData = xSet.getMetaData() ;
int numOfColumns = rsMetaData.getColumnCount() ;

Is This Answer Correct ?    12 Yes 2 No

Post New Answer

More JDBC Interview Questions

Hi my doubt is that preparedStatement is a interface means which has no implemenation.plz go thru the code below String sql = "SELECT * FROM movies WHERE year_made = ?"; prest = con.prepareStatement(sql); prest.setInt(1,2002); ResultSet rs1 = prest.executeQuery(); Now setInt and executeQuery how it works since it is interface it does not have implementation how it works, how executeQuery returns result from database as executequery method has no implementation even in Statement interface.

4 Answers   Cybermate, Hexaware,


What are 4 drivers available in JDBC? At what situation are four of the drivers used?

0 Answers  


Write a program JDBCcode forfetching student database with SQL.

0 Answers  


What are the jdbc drivers in java?

0 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 different types of ResultSet?

0 Answers  


How do you know which driver is connected to a database?

3 Answers  


What is the difference between triggers and procedures?

1 Answers  


What is jdbc thin client in oracle?

0 Answers  


What is serialization and deserialization in java programming?

0 Answers  


How can we store the file in the oracle database?

0 Answers  


How vendor Naming registry supports JNDI?

0 Answers  


Categories