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 are the jdbc drivers in java?
What is meant by dao?
What is the return type of execute, executequery and executeupdate?
What is jdbc vs odbc?
How can we retrieve the file in the oracle database?
Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?
What is the purpose of the jdbc resultset interface?
What is correlated subquery?
What is the use of dialect?
What is jdbc? Describe the steps needed to execute a sql query using jdbc.
What is an odbc driver?
Is jdbc faster than odbc?
Where jdbc drivermanager class is used?
What is setautocommit in jdbc?
List the common jdbc exceptions ?