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!
> 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
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
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