• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

oracle db and java connection

 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m gettin no errors and no outputs,... wats the deal??

here's the code..


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34214
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are hiding the exception. Change

to


I modified your post to use code tags for you to make it easier to read.
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12100
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now you know whey you should never swallow an exception:

An exception is thrown, you basically discard it, and throw it away. So you never know what happened...
 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at OracleExample.main(OracleExample.java:9)

Did the changes you told me. This is the error Im getting now. Totally confused. :/
 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
though I have copied the oracle jar files in my classpath.. and made a DNS connection.. Im not getting an output..
 
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
The error means that the Oracle JDBC driver cannot be found on the classpath, so you've set the classpath incorrectly. How is your classpath set?
 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I went to environment variables> system variables> classpath> .;C:\Programfiles\JAVA\jre7\lib\ext

I copied ojdbc14.jar and ojdbc14_g.jar here. Where did I went wrong?
 
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
You'll have to put the JAR file itself in the classpath, not just the directory that contains the JAR file.
 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried still I am gettingg the same error. This is a runtime error. do I have to put the classpath in system variables or the user variables??
 
RatiKanta pal
Ranch Hand
Posts: 88
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I too had same problem long back.That time i put the ojdbc14.jar inside server(eg: c:\program files\tomcat 6\lib) installed directory.
And the issue was resoved.Try this it might help.

 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing this without using any IDE. I moved the file to jre7. Still I'm getting a runtime error




java.sql.SQLException: No suitable driver found for jdbc:oracle:thin: @localhost
:1522:hr
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at OracleExample.main(OracleExample.java:10)..
 
RatiKanta pal
Ranch Hand
Posts: 88
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey check out this topic it might help..

webpage

webpage2
 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using netbeans.. I'm getting following errors..

run:
Error: Could not find or load main class oracleexample.OracleExample
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
 
Divya Chandel
Ranch Hand
Posts: 47
MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add ojdbc14.jar to java build path of your project.
Thanks
 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did. doesnt work.

Java 7 , netbeans 1.7 , oracle 10g. any problem with that?
 
Divya Chandel
Ranch Hand
Posts: 47
MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this may be it will work-

Create a new folder name 'lib' in your project inside WEB--->WEB-INF folder and copy the jar inside that lib folder.
Than clean and build your project in Netbeans and Run it.

Thanks


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic