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 drivermanager in jdbc?

971


How do I load a database driver with JDBC 4.0 / Java 6?

990


How can I use the JDBC API to access a desktop database like Microsoft Access over the network?

1021


Why would you use setautocommit(false) in jdbc?

1205


Why “no suitable driver” error occurs?

1088


Is jdbc a protocol?

937


What is database deadlock ? How can we avoid them?

1056


What is difference between odbc and jdbc?

1026


What are the flow statements of jdbc?

1008


Describe the steps needed to execute a sql query using jdbc.

984


What is the function of drivermanager class?

1101


How do I know which jdbc driver to use?

1009


Why is jdbc needed?

909


Is odbc an api?

1041


What types of DataSource objects are specified in the Optional Package?

1010