INTERVIEW QUESTIONS
J2EE
JDBC
DETAILS
Question: What are the steps for connecting to the database using JDBC?
Answer: Steps for connecting database through JDBC 1 load the Driver Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); this is Type1 driver.Its also called JDBC-ODBC Bridge. 2 Establish the connection conn=DriverManager.getConnection("jdbc:odbc:rahul","",""); here rahul is DSN(can be user DSN or system DSN), it eliminates the need of providing username & password now connection is established & query can be fired Submitted by Rahul Saxena ([email protected])
|
Question:
What are the steps for connecting to the database using JDBC?
Answer:
Steps for connecting database through JDBC 1 load the Driver Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); this is Type1 driver.Its also called JDBC-ODBC Bridge. 2 Establish the connection conn=DriverManager.getConnection("jdbc:odbc:rahul","",""); here rahul is DSN(can be user DSN or system DSN), it eliminates the need of providing username & password now connection is established & query can be fired Submitted by Rahul Saxena ([email protected]) Source: CoolInterview.com
1) Load the driver- Class.forName("oracle.jdbc.Driver.OracleDriver"); This is type 4 driver it is also called Thin driver.. 2) Establish the connection- Connection con=DriverManager.getConnection("jdbc:oracle:OracleDriver:thin:@localhost:1521","scott","tiger");
Now connection is established & query canbe fired... Source: CoolInterview.com
Answered by: Navneet Kumar Amit | Date: 3/31/2010
| Contact Navneet Kumar Amit
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.
|