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 setautocommit in jdbc?
Explain the JDBC Architecture?
Which type of driver provides jdbc access via one or more odbc drivers?
Why would you use setautocommit(false) in jdbc?
How do I know which jdbc driver to use?
What is jdbc and explain jdbc architecture?
What are the advantages of collection pools?
What is jndi lookup?
What does setautocommit do?
What is jdbc odbc in java?
Where is mysql jdbc driver located?
How to use JDBC API to call Stored Procedures?
What is the return type of class.forname() method?
What is the difference between executing, executequery, executeupdate in jdbc?
What is jdbc drivers in java?