File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes jdbc connection !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc connection !!" Watch "jdbc connection !!" New topic
Author

jdbc connection !!

sasank manohar
Ranch Hand

Joined: Feb 14, 2008
Posts: 186
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 !!


"SCJP5 | SCWCD5| DEVELOPER"
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13881
    
  10

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
sasank manohar
Ranch Hand

Joined: Feb 14, 2008
Posts: 186
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

Joined: Apr 14, 2004
Posts: 10336


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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc connection !!
 
Similar Threads
Execution Problem
java.lang.NoClassDefFoundError: error when try to start websphere server
Cannot find org.apache.commons.javaflow
ClassNotFoundException while running jdbc program
Problems with Jasper Reports