Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to find total column from a resultset?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the meaning of connection?

909


How do I start debugging problems related to the JDBC API?

959


What is jdbc in dbms?

952


What is jdbc architecture?

971


How can I determine where a given table is referenced via foreign keys?

951


What do you understand by DDL and DML statements?

869


What is jdbc and jdbc drivers?

934


How to make updates to updatable result sets in jdbc?

851


What is a JDBC 2.0 DataSource?

931


How many types of jdbc drivers are available?

885


What is a jdbc connection string?

873


What are the different types of lockings in jdbc?

855


How to check jdbc driver version in sql server?

900


What is jdbc odbc connection?

924


What are the differences between execute, executequery, and executeupdate?

905