Home arrow static arrow Java Programming [Archive] - JDBC classpath
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - JDBC classpath
This topic has 7 replies on 1 page.

Posts:5
Registered: 7/6/04
JDBC classpath  
Jul 7, 2004 9:05 AM



 
I installed JDBC driver for sql (jdk 1.4.2). I am using net beans3.6. I also set the classpath but looks like the IDE is ignoring the system variable classpath i set. Any suggestions??

I am currently using odbc but would like a jdbc connectivity.
In my code i have something like Class.forName("com.microsoft.sql.jdbc"). It is unable to find the microsoft package under com.
 

Posts:24,036
Registered: 2/3/03
Re: JDBC classpath  
Jul 7, 2004 9:12 AM (reply 1 of 7)



 
Any suggestions??

Stay out of the IDE until you fully understand classpath.

It is unable to find the microsoft package under com.

Have you added the jar file that contains this class to the compile-time and run-time classpaths?
 

Posts:24,036
Registered: 2/3/03
Re: JDBC classpath  
Jul 7, 2004 9:12 AM (reply 2 of 7)



 
Oh yeah - helpful resources:

[url=http://wiki.java.net/bin/view/Javapedia/ClassPath]The Gateway to Classpath Nirvana[/url]
[url=http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html]Setting the class path[/url] (Windows)
[url=http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html]How Classes are Found[/url]
 

Posts:6,147
Registered: 11/9/00
Re: JDBC classpath  
Jul 7, 2004 9:18 AM (reply 3 of 7)



 
If you want Netbeans to acces a jar file put it in lib/ext under the netbeans directory.
 

Posts:5
Registered: 7/6/04
Re: JDBC classpath  
Jul 7, 2004 9:30 AM (reply 4 of 7)



 
thanks, i will try that
 

Posts:6,147
Registered: 11/9/00
Re: JDBC classpath  
Jul 7, 2004 9:47 AM (reply 5 of 7)



 
Hang on though. That's if you want Netbeans itself to access a library (e.g. using the database tool).

If what you're trying to do is to run a program under Netbeans with a library file do the following.

Right-click the top icon in the Filesystem explorer (the Filesystems icon). From the topical menu chose "Customise".

On the window that comes up right-click the "Java libraries" and select Add/Archives. Then select your jar file.
 

Posts:21,719
Registered: 98-02-20
Re: JDBC classpath  
Jul 7, 2004 10:20 AM (reply 6 of 7)



 
If you want Netbeans to acces a jar file put it in lib/ext under the netbeans directory.

JDBC JARs don't belong in that directory. That's for Java extensions (packages that being with "javax").

Tossing stuff into lib/ext is for folks who can't be bothered to learn how CLASSPATH really works. I think it's bad advice, a poor shortcut.

If NetBeans is like Eclipse, there's a way to add 3rd party JARs to your project CLASSPATH. Best to look in the docs or a tutorial to learn how to do it right.

%
 

Posts:21,719
Registered: 98-02-20
Re: JDBC classpath  
Jul 7, 2004 10:21 AM (reply 7 of 7)



 
Hang on though. That's if you want Netbeans itself to
access a library (e.g. using the database tool).

If what you're trying to do is to run a program
under Netbeans with a library file do the following.

Right-click the top icon in the Filesystem explorer
(the Filesystems icon). From the topical menu chose
"Customise".

On the window that comes up right-click the "Java
libraries" and select Add/Archives. Then select your
jar file.

I didn't see that malcolmmc had this advice following his first thought. I like this much better.

%
 
This topic has 7 replies on 1 page.