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 |
Explain the steps in writing a java program using jdbc?
How does a custom RowSetReader get called from a CachedRowSet?
How to know howmuch data is truncated?
What is the use of JDBC DriverManager class?
Differentiate between type_scroll_insensitive and type_scroll_sensitive.
Explain about DSN?
i am user who logined the application..after that another valid user will also logind..so that is it neccessary to create jdbc connection for each and every user...plz explain it with proper answer...plz help me
What is com mysql jdbc driver?
what are the types of result sets in JDBC 3.0 ?
What is jdbc driver manager?
What is the JDBC syntax for using a literal or variable in a standard Statement?
How to check jdbc driver version in sql server?