944,120 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 4997
  • JSP RSS
Apr 27th, 2006
0

somthing wrong about using JDBC-ODBC

Expand Post »
what I use is SQL SERVER 2000,the system is WINXP SP-2
I set the classpath:C:\Borland\JBuilder2005\jdk1.4\lib;.;C:\Program Files\Tomcat 5.0\common\lib;.;
I use the JDBC-ODBC to connect the database,the original code is

package hospital.db;

import java.sql.*;
import hospital.db.*;

public abstract class DBConnection
{
private static Connection conn = null;
public static Connection getConnection()
{
try
{
if(conn == null)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");
System.out.println("Connection created.");
}
else
{
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select count from administrator");
if(rs == null || !rs.next())
{
Class.forName("san.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");
System.out.println("Connection re-created.");
}
}
catch(Exception ex)
{
System.out.println(ex);
}
finally
{
return conn;
}
}
}

there is no problem in connection the database:Connection created. 2006-04-12 11:34:33
but when I put it into the Tomcat 5.0,it always throw something like:
sun.jdbc.odbc.JdbcOdbc.createSQLException() Ln6958[Microsoft][ODBC SQL Server Driver]
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
forrest is offline Offline
2 posts
since Apr 2006
May 4th, 2006
0

Re: somthing wrong about using JDBC-ODBC

Could you add a line to print the stack trace?
ex.printStackTrace();
Reputation Points: 48
Solved Threads: 7
Posting Whiz
aniseed is offline Offline
353 posts
since Apr 2006
May 5th, 2006
0

Re: somthing wrong about using JDBC-ODBC

Try adding the following to the policy file:
JSP Syntax (Toggle Plain Text)
  1. grant {
  2. permission java.lang.RuntimePermission
  3. "accessClassInPackage.sun.jdbc.odbc";
  4. permission java.util.PropertyPermission
  5. "file.encoding", "read";
  6. };

the policy file is located under JRE_HOME lib/security

or tomcat may have its own, you will have to search for
a file with poilcy in the name under the tomcat base
directory
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
May 5th, 2006
0

Re: somthing wrong about using JDBC-ODBC

i think there will be problem with the odbc driver you have selected. test the DSN while ur creating. and there may also authendication problem. so check with authendication u have selected with sqlserver.

Its

Pon.logeswaran
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ponloges is offline Offline
2 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: debug jsp in tomcat 5.5.7 on windows
Next Thread in JSP Forum Timeline: connecting jsp with oracle database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC