CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS J2EE JDBC DETAILS
Question :
How can you retrieve data from the ResultSet?
Category JDBC Interview Questions
Rating (5.0) By 8 users
Added on 7/14/2006
Views 1486
Rate it!
Answers:

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(SELECT COF_NAME, PRICE FROM COFFEES");
while (rs .next() )
{
//Iam assuming there are 3 columns in the table.
System.out.println ( rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
}

//don't forget to close the resultset, statement & connection

rs.close(); //First
stmt.close(); //Second
con.close(); //Last
System.out.println("You are done");



Connection con=null;
ResultSet rs=null;
//write your own code for Making connection to ur database
String Query="Select * from emp";
try
{
Statement stmt=con.CreateStatement(
rs=stmt.executeQury(Query);
while(rs.next()
{
System.out.println(rs.getString(1)+" "+rs.getString(2));
stmt.close();
rs.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
finally
{
try
{
if(con!=null)
con.close();
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}



 Posted by: Sudhansu Sekhar Behera    

Contact Sudhansu Sekhar Behera  Contact Sudhansu Sekhar Behera


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
How do you implement Connection Pooling
View Answer
What are the steps for connecting to the database using JDBC
View Answer
While in CallableStatament using in the oracle my procedure is return no.of columns so in java
View Answer
How to call a Stored Procedure from JDBC?
View Answer
What Class.forName will do while loading drivers?
View Answer
What packages are used by JDBC?
View Answer
What are the common tasks of JDBC?
View Answer
What Class.forName( ) method will do?
View Answer
How to get the resultset of stroedProcedure
View Answer
How can store images in a data base?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL JDBC Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/5015/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.64