Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / May 2006

Tip: Looking for answers? Try searching our database.

Connecting to MS Access Using Java

Thread view: 
questionmarc420@msn.com - 24 May 2006 21:17 GMT
hi,
im having toruble connecting to MS Access DB using Java.
This is the code i used:

public void connect(){

               try {
                       Class.forName("sun.jdbc.odbc.JbdcOdbcDriver");
               } catch (ClassNotFoundException e) {
                       e.printStackTrace();
               }

               String databaseName = "invent";
       String url = "jdbc:odbc:" + databaseName;
       String loginName = "Admin";
       String password = "lace";

       try {
                       conn01 = DriverManager.getConnection(url,
loginName, password);
               } catch (SQLException e) {
                       e.printStackTrace();
               }
       }

this is the error i get:

java.lang.ClassNotFoundException: sun.jdbc.odbc.JbdcOdbcDriver
       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)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Unknown Source)
       at allm.test.DBaccess.connect(DBaccess.java:18)
       at allm.test.test.main(test.java:17)
java.sql.SQLException: No suitable driver
       at java.sql.DriverManager.getConnection(Unknown Source)
       at java.sql.DriverManager.getConnection(Unknown Source)
       at allm.test.DBaccess.connect(DBaccess.java:29)
       at allm.test.test.main(test.java:17)

can somebody please pooint me in the right direction.
do i need to configure somethign in access? is there any thing i have
to do in the ODBC configurations?

any help is appreciated.
thanks in advance
-morc
Bjorn Abelli - 24 May 2006 21:38 GMT
<questionmarc420@msn.com> wrote...

[snipped down to the essentials]

> java.lang.ClassNotFoundException: sun.jdbc.odbc.JbdcOdbcDriver

...

> java.sql.SQLException: No suitable driver

> can somebody please pooint me in the right direction.
> do i need to configure somethign in access? is there
> any thing i have to do in the ODBC configurations?

Probably not. It seems more likely that either:

- you're running it as an applet in old IE
 (didn't have that bridge class, but a MS one)

- you're running on an obscure, stripped down
 version of the JRE (where that driver is missing)

- something's wrong with your JRE installation, so the
 JVM doesn't find the Java classes

- or you're executing the app in a way that overrides the
 default classpaths.

There could possibly be other possible causes to your error as well, but
these are some that comes up on the top of my head.

In order to help you better, you could provide more info on what version of
JRE, JVM, OS, etc, you're running it on.

// Bjorn A
morc - 24 May 2006 21:52 GMT
thanks for the reply.
i am using windows xp, mcirsoft access 2003,  J2SE Development kit 5.0,
J2SE Runtime Enviroment 5.0

your help is apprefciated
-morc
Bjorn Abelli - 24 May 2006 22:59 GMT
"morc" wrote...
> thanks for the reply.
> i am using windows xp, mcirsoft access 2003,
> J2SE Development kit 5.0,
> J2SE Runtime Enviroment 5.0
>
> your help is apprefciated

 java.lang.ClassNotFoundException:
 sun.jdbc.odbc.JbdcOdbcDriver

Now I saw the error ;-)

You have simply spelled the name wrong.

JbdcOdbcDriver should be JdbcOdbcDriver

// Bjorn A
IchBin - 24 May 2006 23:12 GMT
> "morc" wrote...
>> thanks for the reply.
[quoted text clipped - 16 lines]
>
> Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php

Boy.. I would have never picked that up!..

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)
morc - 25 May 2006 14:41 GMT
thanks alot. it worked i was gettin frustrated :)
IchBin - 24 May 2006 22:03 GMT
> hi,
> im having toruble connecting to MS Access DB using Java.
> This is the code i used:
[snip]

I do not have access installed. The "sun.jdbc.odbc.JbdcOdbcDriver"
class can not be found.  Think you can download from a list here..

http://developers.sun.com/product/jdbc/drivers

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)
IchBin - 24 May 2006 22:18 GMT
 > http://developers.sun.com/product/jdbc/drivers

I am running XP SP 2 Home.
I get same results with JDK 1.5.6 and Java 1.6

So I would try a third party driver from that last link I mentioned at Sun.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)
Bjorn Abelli - 24 May 2006 22:38 GMT
> I do not have access installed. The "sun.jdbc.odbc.JbdcOdbcDriver" class
> can not be found.  Think you can download from a list here..

That shouldn't be necessary, as sun.jdbc.odbc.JbdcOdbcDriver is shipped with
the default libraries from Sun, in rt.jar.

// Bjorn A


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.