Code for connecting java with oracle

Showing Answers 1 - 2 of 2 Answers

we have four different ways in connecting to oracle or any database

create a dsn first then use the following statements

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection("jdbc:odbc:dsnname","username","password");

Statement stmt = con.createStatement();

  Was this answer useful?  Yes

phani

  • Oct 9th, 2006
 

first find what kind of driver ur using...

if ur using oracle10g (ie type 4 driver)the code is

class.forName("Oracle.jdbc.driver.OracleDriver");

connection con=DriverManager.getConncetion("jdbc:oracle:thin:@localhost:1521:xe","scott","tiger");

Statement stmt=con.createstatement();

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions