Results 1 to 10 of 10
Thread: cannot connect to oracle DB
- 12-03-2010, 05:02 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 7
- Rep Power
- 0
cannot connect to oracle DB
I'm trying to connect to an oracle data base from my netbean's application ,
I've already added the jdbc to the library
I've wrote the appropriate code but it's not working
here's the code
and here's the output messageJava Code:package connection; import java.sql.DriverManager; import java.sql.Connection; import java.sql.*; public class connection { public static void main(String[] args) throws SQLException{ try{ Class.forName("oracle.jdbc.OracleDriver"); System.out.println("Chargement du driver jdbc ds la JVM réussie"); Connection con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:GLOBAL","SYSTEM", "manager"); System.out.println("Connexion réussite"); Statement stmtCode = con.createStatement(); ResultSet rs = stmtCode.executeQuery("select note1,note2 from T2"); while(rs.next()) System.out.println(rs.getFloat(1) + " " + rs.getFloat(2)); rs.close(); } catch(Exception e) { e.printStackTrace(); } } }Java Code:run: Chargement du driver jdbc ds la JVM réussie java.lang.ArrayIndexOutOfBoundsException: 4 at oracle.jdbc.driver.T4C8TTIdty.<init>(T4C8TTIdty.java:479) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1113) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:308) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:185) at connection.connection.main(connection.java:12) BUILD SUCCESSFUL (total time: 3 seconds)
Any help would be appreciated, thanks.
- 12-04-2010, 07:44 AM #2
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
try
Java Code:Class.forName("oracle.jdbc.driver.OracleDriver");
instead of
Java Code:Class.forName("oracle.jdbc.OracleDriver");
- 12-04-2010, 09:15 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 7
- Rep Power
- 0
hi mine
thank you for answering ,
I've added "driver" in class.forname like you mentioned and it's still generating the SAME output message , no changes
- 12-06-2010, 12:49 AM #4
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Seem that the error you are getting is about drivers or/and library.
Where did you get the library that you add?
I am not sure with this, I have'nt try to install oracle before but just want to ask:
Are you sure that the port 1521 is the port that you enter when you install oracle thin?
- 12-06-2010, 10:22 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
What version of Oracle do you have?
What version of the driver are you using?
What version of Java are you using?
- 12-06-2010, 10:02 PM #6
Member
- Join Date
- Dec 2010
- Posts
- 7
- Rep Power
- 0
hi
I was using oracle 8.1.7 , and I've downloaded ojdbc5.jar from the oracle official site ,
Yes I'm sure of the port 1521 this is the default one , and i've created my table after being connected with the system account
ok, which is really strange that I've installed oracle 10 express after, added to my library's application a jdbc that I've found in that oracle 10 directory
now it works !!!
so does the oracle 8.1.7 version having problem's connection ?
thanks
- 12-07-2010, 09:03 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Yes.
Oracle 8i is no longer supported, and hasn't been for a while, so I wouldn't be surprised to find that a JDBC driver designed for Oracle 10 doesn't work with it.
If you need to use Oracle 8i then you'll want to get hold of the classes12 zip.
- 12-07-2010, 10:37 AM #8
Member
- Join Date
- Dec 2010
- Posts
- 7
- Rep Power
- 0
hi Tolls
thank you for your answer , I downloaded classes12.zip and I didn't understand what to do with the classes within :)
I'm used to .jars files so I prefer to continue manipulating oracle 10, the connection succeeded simply :)
thanks
- 12-07-2010, 11:00 AM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Don't unzip it.
It is a jar file...it's just called a zip for some unknown reason.
Use it like any other jar file.
- 12-09-2010, 12:08 PM #10
Member
- Join Date
- Dec 2010
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
connect to oracle from java
By ahmadian in forum Advanced JavaReplies: 7Last Post: 05-15-2013, 04:15 PM -
Oracle Connect thru register driver
By chyrl in forum JDBCReplies: 5Last Post: 05-11-2010, 03:45 PM -
new to oracle
By emmett01 in forum JDBCReplies: 4Last Post: 11-15-2009, 06:16 AM -
why oracle index can't work correctly in oracle?
By wwwlife in forum JDBCReplies: 0Last Post: 08-27-2008, 09:27 AM -
Using JDBC to connect to ORACLE database
By Java Tip in forum Java TipReplies: 0Last Post: 02-10-2008, 11:27 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks