Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need Help with Java Database Connectivity

3 views
Skip to first unread message

Tom

unread,
Aug 11, 2003, 1:39:26 PM8/11/03
to
Hello,

I was wondering if anyone could help me out. Im a student and im
making a project where i can access data in my Microsoft SQL 2000
local database, change it, delete it, ect.

I have all the groundwork laid out but im having problems with the
actual connection to the database.

I downloaded a JDBC driver for sql 2000, but when i compile the
program im getting these connection errors

java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:172)
at BookProject.CloudscapeDataAccess.connect(CloudscapeDataAccess.java:133)
at BookProject.CloudscapeDataAccess.<init>(CloudscapeDataAccess.java:44)
at BookProject.AddressBook.<init>(AddressBook.java:35)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:232)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:582)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:511)
at sun.applet.AppletPanel.run(AppletPanel.java:289)
at java.lang.Thread.run(Thread.java:479)
java.security.AccessControlException: access denied
(java.lang.RuntimePermission exitVM)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:267)
at java.security.AccessController.checkPermission(AccessController.java:394)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:540)
at java.lang.SecurityManager.checkExit(SecurityManager.java:760)
at java.lang.Runtime.exit(Runtime.java:86)
at java.lang.System.exit(System.java:696)
at BookProject.AddressBook.<init>(AddressBook.java:43)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:232)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:582)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:511)
at sun.applet.AppletPanel.run(AppletPanel.java:289)
at java.lang.Thread.run(Thread.java:479)

Which is pointing to no suitable driver. I set the Classpath, but im
not sure what else to do.

Here is my connection code

String url = "jdbc:microsoft:sqlserver://local:1433;User=me;Password=mealso";
connection = DriverManager.getConnection(url,User,Password);
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();

Sorry this is such a long post,
Thanks for the time and help!

Thomas Kellerer

unread,
Aug 11, 2003, 2:09:44 PM8/11/03
to
Tom schrieb:

> Which is pointing to no suitable driver. I set the Classpath, but im
> not sure what else to do.
>
> Here is my connection code
>
> String url = "jdbc:microsoft:sqlserver://local:1433;User=me;Password=mealso";
> connection = DriverManager.getConnection(url,User,Password);
> Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
>
> Sorry this is such a long post,
> Thanks for the time and help!

You need to switch the two lines:

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

registers the driver

After that you can connect. You don't need the newInstance() as registering
occurs in a static initializer of the driver.

Thomas


--
The "From" email address will not be checked by me!
Send private emails to thomas(at)kellerer(dot)org

Tom

unread,
Aug 12, 2003, 5:57:45 PM8/12/03
to
Thomas Kellerer <spam_...@gmx.net> wrote in message news:<bh8m57$l3a$1...@svr8.m-online.net>...

> Tom schrieb:
>
> > Which is pointing to no suitable driver. I set the Classpath, but im
> > not sure what else to do.
> >
> > Here is my connection code
> >
> > String url = "jdbc:microsoft:sqlserver://local:1433;User=me;Password=mealso";
> > connection = DriverManager.getConnection(url,User,Password);
> > Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
> >
> > Sorry this is such a long post,
> > Thanks for the time and help!
>
> You need to switch the two lines:
>
> Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
>
> registers the driver
>
> After that you can connect. You don't need the newInstance() as registering
> occurs in a static initializer of the driver.
>
> Thomas


Thanks for the Help!
I really appreciate it

I switched the two lines and have a different error now,
If you got time id appreciate another suggestion

this error reads java.lang.ClassNotFoundException: java.io.IOException:
open HTTP connection Failed

Thomas Kellerer

unread,
Aug 13, 2003, 2:50:27 AM8/13/03
to

Tom schrieb:


>
> Thanks for the Help!
> I really appreciate it
>
> I switched the two lines and have a different error now,
> If you got time id appreciate another suggestion
>
> this error reads java.lang.ClassNotFoundException: java.io.IOException:
> open HTTP connection Failed

ClassNotFoundException indicates that you did not put the necessary jar files in
to your classpath when running the application.

I don't have a clue why you are getting an HTTP connection error though

Thomas

0 new messages