|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: JDBC with Oracle (merged) [message #493036 is a reply to message #493030] |
Fri, 04 February 2011 06:16 |
|
Michel Cadot
Messages: 68686 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
C:\>type Conn.java
import java.sql.*;
class Conn
{
public static void main (String args [])
throws ClassNotFoundException,SQLException
{
// Class.forName ("oracle.jdbc.Driver.OracleDriver");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println("Hello");
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci8:@mika", "michel", "michel");
System.out.println("Successfully connected with OCI driver");
conn.close();
conn = DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1530:mika", "michel", "michel");
System.out.println("Successfully connected with thin driver");
conn.close();
}
}
C:\>javac Conn.java
C:\>java Conn
Hello
Successfully connected with OCI driver
Successfully connected with thin driver
C:\>set
CLASSPATH=.;C:\oracle\ora1024\jdbc\lib\classes12.zip
ORACLE_HOME=C:\oracle\ora1024
ORACLE_SID=MIKA
Path=C:\oracle\ora1024\jdk\bin;C:\oracle\ora1024\bin;C:\oracle\ora1024\lib;
C:\oracle\ora1024\OPatch;C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;
windir=C:\WINDOWS
As I said use "DriverManager.registerDriver" NOT "Class.forName".
Regards
Michel
[Updated on: Fri, 04 February 2011 06:17] Report message to a moderator
|
|
|