If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > db2 and JDBC

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-02-11, 09:31
saurabhsood saurabhsood is offline
Registered User
 
Join Date: Mar 2011
Posts: 5
db2 and JDBC

i am making an application in Java using db2 as backend. I have db2 installed, and using the db2inst1 user, I am able to connect to the database and access the information, but using an existing user, it gives me the ClassNotFoundException. I am using db2 express C 9.7 on ubuntu 10.10.

pls help

thnx...
Reply With Quote
  #2 (permalink)  
Old 03-02-11, 10:00
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What are you trying to execute when you get the exception? What is the full exception you are getting?

Andy
Reply With Quote
  #3 (permalink)  
Old 03-02-11, 10:51
saurabhsood saurabhsood is offline
Registered User
 
Join Date: Mar 2011
Posts: 5
am getting this error...

java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
at java.net.URLClassLoader$1****n(URLClassLoader.java :217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at trials.db2query.main(db2query.java:14)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Reply With Quote
  #4 (permalink)  
Old 03-02-11, 10:54
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Your JDBC driver is not in your classpath.

Andy
Reply With Quote
  #5 (permalink)  
Old 03-02-11, 10:57
saurabhsood saurabhsood is offline
Registered User
 
Join Date: Mar 2011
Posts: 5
how to set the classpath in linux?
Reply With Quote
  #6 (permalink)  
Old 03-02-11, 11:18
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Reply With Quote
  #7 (permalink)  
Old 03-02-11, 11:22
saurabhsood saurabhsood is offline
Registered User
 
Join Date: Mar 2011
Posts: 5
how do i set it for the db2 jdbc driver?
Reply With Quote
  #8 (permalink)  
Old 03-02-11, 11:31
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
It depends on where it is. You should check your classpath for db2inst1 and set the classpath to the same thing for the user.

Andy
Reply With Quote
  #9 (permalink)  
Old 03-02-11, 11:42
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
This is a pure Java question and not related to DB2 at all.

Firt: Do not change (or use) the CLASSPATH variable, it is no longer needed.

When starting your application you need to specify the jar files that your application needs:
Code:
java -cp myapp.jar;db2java.jar mypackage.MyMain
For more details refer to the manual:
http://download.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html
Reply With Quote
  #10 (permalink)  
Old 03-02-11, 11:46
saurabhsood saurabhsood is offline
Registered User
 
Join Date: Mar 2011
Posts: 5
setting the classpath didnt work for (might have done it wrong). though, i managed to get it working by including the driver using netbeans. now i am able to connect to the database

thnx for the response...
Reply With Quote
  #11 (permalink)  
Old 03-02-11, 11:55
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
As I said: do not use CLASSPATH.

"Including the driver using netbeans" is essentially providing the necessary information for the -cp parameter.

Please do read the link I posted. This is absolute basic Java knowledge
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On