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


INTERVIEW QUESTIONS J2EE JAVA DETAILS
Question :
What is JDBC? Describe the steps needed to execute a SQL query using JDBC.
Category Java Interview Questions
Rating (3.4) By 12 users
Added on 10/13/2004
Views 1826
Rate it!
Answers:

The JDBC is a pure Java API used to execute SQL statements. It provides a set of classes and interfaces that can be used by developers to write database applications.
The steps needed to execute a SQL query using JDBC:
1. Open a connection to the database.
2. Execute a SQL statement.
3. Process th results.
4. Close the connection to the database.



Hi...
JDBC: JDBC is a specification which allows the developers to communicating from front end(java) to back end(oracle,sybase...).
The standard steps to connecting the database as follows:
try{
1: Loading the drivers
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
2:Getting the connection
Connection con=DriverManager.getConnection("jdbc:odbc:datasourcename","scott","tiger");
3:Create the Statement
Statement st=con.createStatement();
4:Execute the Statement
ResultSet rs=st.executeQuery("select * from emp");
5:Accessing the data from the backend
while(rs.next())
System.out.println(rs.getString(1));
System.out.println(rs.getInt(2));
System.out.println(rs.getString(3));
6:close the connection
}catch(SQLException se)
{ se.printStackTrace();
}
finally{
con.close();
rs.close();
st.close();
}



Posted by: DEVARATHNAM C,KOTAGUDIBANDA(PO),KALAKADA(MD),CHITT    

Contact DEVARATHNAM C,KOTAGUDIBANDA(PO),KALAKADA(MD),CHITT Contact DEVARATHNAM C,KOTAGUDIBANDA(PO),KALAKADA(MD),CHITT

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • 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
    Access specifiers: "public", "protected", "private", nothing?
    View Answer
    What does the "final" keyword mean in front of a variable? A method? A class?
    View Answer
    Does Java have "goto"?
    View Answer
    Why "bytecode"? Can you reverse-engineer the code from bytecode?
    View Answer
    What synchronization constructs does Java provide? How do they work?
    View Answer
    Are constructors inherited?Can a subclass call the parent's class constructor?When?
    View Answer
    Does Java have destructors?
    View Answer
    What does the "abstract" keyword mean in front of a method? A class?
    View Answer
    Name four methods every Java class will have.
    View Answer
    Given a text file, input.txt, provide the statement required
    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 Java 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/443/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.83
    Cache = 0 Seconds