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()
if(conn == null)
conn = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");
System.out.println("Connection created.");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select count from administrator");
if(rs == null || !rs.next())
conn = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");
System.out.println("Connection re-created.");
catch(Exception ex)
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]

Try adding the following to the policy file:

grant {
    permission java.lang.RuntimePermission
    permission java.util.PropertyPermission
       "file.encoding", "read";

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

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.



This article has been dead for over six months. Start a new discussion instead.