Results 1 to 5 of 5
- 07-16-2012, 07:45 PM #1
Member
- Join Date
- Jul 2012
- Posts
- 3
- Rep Power
- 0
Exception in thread "main" java.lang.ClassNotFoundException: jdbc.odbc.driver.Oracle
I am using Netbeans 7.1.2. I have been having a terrible time trying to connect to a remote Oracle database. I was given the appropriate url from my professor, and told to install ojdbc.6 from Oracle which I did by adding it to the class path, but I'm still having no luck at all actually getting the data from the database. I can go in manually and connect. I am using the simple code below (from my text) to try to start troubleshooting the issue - see below. Any help that can be given would be super appreciated.
Exception info is below:Java Code:package javaapplication6; import java.sql.*; public class JavaApplication6 { public static void main(String[] args) throws SQLException, ClassNotFoundException { Class.forName("jdbc.odbc.driver.OracleDriver"); System.out.println("Driver loaded"); Connection connection = DriverManager.getConnection ("jdbc:oracle:thin:@XXXXX:port:xxxx","username","password"); System.out.println("Database connected"); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT * FROM POWER"); while (resultSet.next()) System.out.println(resultSet.getString(2)); connection.close(); } }
run:
Exception in thread "main" java.lang.ClassNotFoundException: jdbc.odbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at javaapplication6.JavaApplication6.main(JavaApplica tion6.java:11)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)Last edited by jkjmomadad; 07-16-2012 at 07:47 PM.
- 07-16-2012, 09:23 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
Re: Exception in thread "main" java.lang.ClassNotFoundException: jdbc.odbc.driver.Ora
The exception says otherwise. How are you adding the database driver to the classpath?I did by adding it to the class path
- 07-17-2012, 08:48 AM #3
Member
- Join Date
- Jul 2012
- Posts
- 3
- Rep Power
- 0
Re: Exception in thread "main" java.lang.ClassNotFoundException: jdbc.odbc.driver.Ora
Perhaps I've done it wrong; I right-clicked the project, selected properties, selected Libraries, selected Compile tab, Add Jar/Folder. I then browsed to the copy of ojdbc6.jar that was provided and added it; I see the odjdbc6 driver there which was given to us to install. I'm new to this so any insight you can give would be helpful.
- 07-17-2012, 09:38 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Exception in thread "main" java.lang.ClassNotFoundException: jdbc.odbc.driver.Ora
You don't need the jar file to compile.
You need it at runtime.
I haven't got Netbeans in front of me, but there should be somewhere to tell it that this jar file is a runtime dependency.Please do not ask for code as refusal often offends.
- 07-18-2012, 09:01 AM #5
Member
- Join Date
- Jul 2012
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
"Exception in thread "main" java.lang.NoSuchMethodError: main"
By isnkumar in forum New To JavaReplies: 2Last Post: 06-20-2012, 12:18 AM -
Got struck with this :- " Exception in thread "main" java.lang.NullPointerException"
By Vermont in forum New To JavaReplies: 5Last Post: 12-21-2011, 06:44 PM -
Exception in thread "main" java.lang.NumberFormatException:input string: "060320
By renu in forum New To JavaReplies: 14Last Post: 04-08-2011, 06:01 PM -
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/pool/Orac leDa
By Kirthana in forum JDBCReplies: 0Last Post: 02-11-2011, 03:21 PM -
Question about error "Exception in thread "main" java.lang.NoSuchMethodError: main
By ferdzz in forum New To JavaReplies: 5Last Post: 06-22-2010, 03:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks