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
How can we execute stored procedures using callablestatement?
Why we use jdbc instead of odbc?
How to connect html page to database using jdbc?
Which is best database for java?
What is use of connection pooling?
What are restrictions on triggers?
What is jndi lookup?
Briefly tell about the jdbc architecture.
What is jdbc and jpa?
What does setautocommit do?
What does adapter class provide?
What is jdbc driver for sql server?
Can I get a null resultset?
Is jdbc open source?
Is odbc an api?