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 |
What is the use of callablestatement? Name the method, which is used to prepare a callablestatement.
How to set the attribute concurrency in resultset?
What port does jdbc use?
What does the jdbc connection interface?
What is addbatch jdbc?
How do I find ojdbc jar version?
Is java a database?
What are statements in JAVA ?
can we define indexes on a foreign key? Explain pros and cons?
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.
What are the different types of drivers under jdbc?
What do you understand by jdbc driver and explain its types?