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
What is the use of the statement in jdbc?
Is it possible to connect to multiple databases simultaneously? Using single statement can one update or extract data from multiple databases?
What does setautocommit do?
What are the methods which can verify the cursor particular position?
What are 4 drivers available in JDBC? At what situation are four of the drivers used?
Why resultset is used in java?
What is the difference between executing, executequery, executeupdate in jdbc?
What is a rollback in jdbc?
What are jdbc and its components?
What is two-phase commit in the database?
Explain the JDBC Architecture?
what is the meaning of following code snippets Class c=class.forName(driverClassName); Driver d=(driver)c.newInstance();
Is java a database?
What are the advantages of collection pools?
Name the new features added in jdbc 4.0.