Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc.oracle.thin:@ip
"username
I got the following errors during runtime after various stages and combinations of syntaxes:
1) noclassdeffounderror
2) unsupportedclassversionerror
3) sqlException
After breaking my head for nearly 5 hours I found that the solution is very simple.
What was missing is that the in the jre folder of the java sdk installation the classes12.jar file was not defined which defines the OracleDriver class.
Solution:
just get the classes12.jar file from the oracle folder. For me it was in a folder like:
"C:\oracle\product\10.2.0\db_1\jdbc\lib"
just copy it from the folder defined similarly in your computer and paste it in the folder like:
"C:\JDK\j2sdk1.4.2_13\jre\lib\ext"
and then execute your java program and access your database.
Also i found that we can declare the driver class also as below:
Class.forName("oracle.jdbc.OracleDriver");
It runs just fine :).