• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc connection !!

 
sasank manohar
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!

I have just installed oracle 9i (Oracle9i Enterprise Edition Release 9.2.0.1.0 ) and set the classPath as follows

D:\oracle\ora92\jdbc\lib\ojdbc14.jar;D:\oracle\ora92\jdbc\lib\classes12.jar;

as i have installed it in D:\oracle

what is the problem ? The probem is this, i am not able to execute the following program !!

import java.sql.*;
class Demo
{
public static void main(String []args) throws SQLException,ClassNotFoundException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection ("jdbcracle:thin:@localhost:1521rcl","scott","tiger");
System.out.println("Connection established successfully...");
}
}


I am getting the errors something like this !!

C:\Documents and Settings\sukhdevzcomputer\mypgms\jdbc>java Demo
Exception in thread "main" java.lang.UnsupportedClassVersionError: Demo (Unsuppo
rted major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

The pgm is compiled but while i am trying to execute the program, i am getting these errors( above mentioned).

so can you help me !!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main" java.lang.UnsupportedClassVersionError: Demo (Unsupported major.minor version 49.0)

This means that you are trying to execute a class which was compiled with Java 5 on an older version of Java (1.4 or older).

Make sure you are using the correct Java version. Check which Java version the Oracle JDBC libraries require.

Note: It is not necessary to include both ojdbc14.jar and classes12.jar. As far as I know, classes12.jar is an older version of the Oracle JDBC driver and ojdbc14.jar is a newer version. You need only one of the two.
 
sasank manohar
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have Java 1.5 version installed in my system. so I have
compiled the program and trying to run the program on same version ,
so there no chance of incompatibility as far as the version is concerned .I am not able to understand why I am getting those errors !!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

so there no chance of incompatibility as far as the version is concerned

...well that is what is causing the problem. No doubt about it.

Oracle includes a JDK, and unless you are running Oracle 11g (which from your classpath it looks like you are not) you will have a 1.4.2 JDK on your system. Check your path - make sure you are using the javac you think you are to compile your class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic