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 retrieve sql exceptions

Answer Posted / mukundvishy

Hashtable mapTable = new Hashtable();
Connection sqlCon = null ;
PreparedStatement pStmnt = null ;
ResultSet rSet = null;
try
{
// getConnection() method below should get connection from
pool etc.
sqlCon = getConnection();
pStmnt = sqlCon.prepareStatement( "SELECT * from tab" );
rSet = pStmnt.executeQuery();
while( rSet.next() )
{
mapTable.put( rSet.getString(1), rSet.getString(2));
}

}
catch( SQLException ex )
{
ex.printStackTrace();
}
finally
{
// The below method should close all resources peacefully
closeResources( sqlCon, pStmnt, rSet );
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of the statement in jdbc?

975


Is it possible to connect to multiple databases simultaneously? Using single statement can one update or extract data from multiple databases?

1058


What does setautocommit do?

1020


What are the methods which can verify the cursor particular position?

1073


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

1006


Why resultset is used in java?

982


What is the difference between executing, executequery, executeupdate in jdbc?

1052


What is a rollback in jdbc?

994


What are jdbc and its components?

1018


What is two-phase commit in the database?

1099


Explain the JDBC Architecture?

1066


what is the meaning of following code snippets Class c=class.forName(driverClassName); Driver d=(driver)c.newInstance();

5121


Is java a database?

1008


What are the advantages of collection pools?

1100


Name the new features added in jdbc 4.0.

1025