| Author |
Updated from JRE 1.5 to 1.6, now SQL JDBC Connection doesnt work
|
Bob Meads
Greenhorn
Joined: Nov 06, 2008
Posts: 5
|
|
Help! I am writing an applet that connects to a SQL 2005 database. Originally I had JRE 1.5, and the code below worked fine for connecting to my SQL Server database: ------------------------------------------------------------------------- try{ connectionUrl = "jdbc:sqlserver://MyPC\DS;databaseName=CP243IT_Sample; IntegratedSecurity=True; Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con = DriverManager.getConnection(connectionUrl); bRet = true; // success DBConnected = true; txtMsgArea.append("Successfully connected to database.\r\n"); } // Handle any errors that may have occurred. catch (Exception x) { x.printStackTrace(); bRet = false; // failed txtMsgArea.append("Database connection failed..\r\n" + x.getMessage() + "\r\n"); } -------------------------------------------------------------------------- However after I installed Java 6 for Windows Internet explorer, JRE 1.6, now the code returns an error: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getConnection(DriverManager.java:532) at java.sql.DriverManager.getConnection(DriverManager.java:193) at siemensdatalogger.DataLogger_CP243_IT.ConnectDB(DataLogger_CP243_IT.java:475) What do I need to do to get it working again???
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
Welcome to JavaRanch You are supposed to download a driver for any JDBC connection. A lot of people put it in a Java directory, possibly lib/ext. And when you reinstall Java, you have a different lib/ext directory . . . Try reinstalling the driver. And if you put the driver in a Java folder, you will have to move the driver or something whenever you upgrade your Java installation.
|
 |
Bob Meads
Greenhorn
Joined: Nov 06, 2008
Posts: 5
|
|
Ritchie thanks for your reply.  I am using Borland JBuilder 2005. I had the MS SQL Server drivers installed, basically a folder copy to my Borland directory. In my project, I have an applet that directly references the sqljdbc.jar file. This path is still valid but I re-downloaded the files anyway. When I run the applet in the debug app in JBuilder, I get: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getConnection(DriverManager.java:532) at java.sql.DriverManager.getConnection(DriverManager.java:193) When I run it fron an HTML page in the same folder as the applet, I get: Java.security.AccessControlException: access denied (java.lang.RuntimePermission loadLibrary.sqljdbc_auth.dll) at java.security.AccessControlContext.checkPermission(Unknown Source) Any thoughts? have some security settings changed? YIKES!  [ November 06, 2008: Message edited by: Bob Meads ]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
Applets? Applets? Bound to be a security settings problem.
|
 |
Bob Meads
Greenhorn
Joined: Nov 06, 2008
Posts: 5
|
|
|
Since I didnt have the issue before, how can I debug it?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
I don't know. Sorry. Anybody else?
|
 |
Bob Meads
Greenhorn
Joined: Nov 06, 2008
Posts: 5
|
|
I figured it out. Basically, installing a new version of Java JRE will have its own Java.Policy file; the browser of course will use the latest JRE and security policies when running applets. the fix was to update the java.policy file to allow the driver access to the SQL Server IP address. I dont know why JBUilder's debug environment wont recognize the SQL driver anymore, but since the htrml page is working, I will just use that. thanks
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
Originally posted by Bob Meads: I figured it out
Well done. And thank you for telling us the solution; it will be useful if anybody has a similar problem in the future.
|
 |
Bob Meads
Greenhorn
Joined: Nov 06, 2008
Posts: 5
|
|
You are welcomed.
|
 |
 |
|
|
subject: Updated from JRE 1.5 to 1.6, now SQL JDBC Connection doesnt work
|
|
|