|
INTERVIEW QUESTIONS
J2EE
JAVA
DETAILS
Question: What is JDBC? Describe the steps needed to execute a SQL query using JDBC.
Answer: 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.
|
|
|
Category |
Java Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 10098 users |
Added on |
10/13/2009 |
Views |
76945 |
Rate it! |
|
|
Question:
What is JDBC? Describe the steps needed to execute a SQL query using JDBC.
Answer:
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. Source: CoolInterview.com
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(); } Source: CoolInterview.com
Answered by: DEVARATHNAM C,KOTAGUDIBANDA(PO),KALAKADA(MD),CHITT | Date:
| 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.
|
|
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
|
|
Discuss the differences between creating a new class, extending a class and implementing an interface; and when each would be appropriate.
|
View Answer
|
|
What's the difference between the == operator and the equals() method? What test does Object.equals() use, and why?
|
View Answer
|
|
Why do you create interfaces, and when MUST you use one?
|
View Answer
|
|
What is the difference between instanceof and isInstance?
|
View Answer
|
|
Are there any other 'marker' interfaces?
|
View Answer
|
|
How many methods do u implement if implement the Serializable Interface?
|
View Answer
|
|
What are the advantages of OOPL?
|
View Answer
|
|
What do mean by polymorphism, inheritance, encapsulation?
|
View Answer
|
|
What do you mean by static methods?
|
View Answer
|
|
What do you mean by virtual methods?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Java Interview Questions & Answers - Exam Mode /
Learning Mode
|