Click to See Complete Forum and Search --> : How to use Java connect to Oracle


drakman
03-07-2006, 10:16 PM
I need to use java connect to Oracle database. Please tell me how to use and I want script to connect, Thank you. :eek:

drakman
03-07-2006, 10:19 PM
Good idea

Khalid Ali
03-07-2006, 10:51 PM
Good idea

?????what is good idea..:-)

Ozi
03-09-2006, 07:37 AM
well first of all you need to import the java.sql.*; statement at the beginning of your source code before the class decleration.

here is the java api
http://java.sun.com/j2se/1.4.2/docs/api/

try looking for it on there, its very helpful

Khalid Ali
03-09-2006, 07:47 AM
to connect to oracle he first needs to put oracle driver files in the path, and then do the imports..:-)

BigDog
03-09-2006, 08:33 AM
It is just like for any other JDBC connection. Here is an example:

String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
// Create a connection to the database
String serverName = "machine_name";
String portNumber = "1521";
String sid = "oracle_sid";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "user/schema name";
Connection connection = DriverManager.getConnection(url, username, password);
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select * from some_table");