com.microsoft.jdbc.sqlserver.SQLServerDriver在linux下连接问题
MarsZ 2003-10-15 01:20:53 代码如下
//--------------------Test.java----------------------------------------//
import java.sql.*;
/**
* Microsoft SQL Server JDBC test program
*/
public class Test {
public Test() throws Exception {
// Get connection
DriverManager.registerDriver(new
com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test","sa","xxxx");
if (connection != null) {
System.out.println();
System.out.println("Successfully connected");
System.out.println();
// Meta data
DatabaseMetaData meta = connection.getMetaData();
System.out.println("\nDriver Information");
System.out.println("Driver Name: "
+ meta.getDriverName());
System.out.println("Driver Version: "
+ meta.getDriverVersion());
System.out.println("\nDatabase Information ");
System.out.println("Database Name: "
+ meta.getDatabaseProductName());
System.out.println("Database Version: "+
meta.getDatabaseProductVersion());
}
} // Test
public static void main (String args[]) throws Exception {
Test test = new Test();
}
}
//--
windows下jdk1.4.2运行连接正确,输出:
Successfully connected
Driver Information
Driver Name: SQLServer
Driver Version: 2.2.0029
Database Information
Database Name: Microsoft SQL Server
Database Version: Microsoft SQL Server 2000 - 8.00.194 (Intel X86)
Aug 6 2000 00:57:48
Copyright (c) 1988-2000 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 1)
换到linux下运行(当然jdbc url中localhost已经改成相应的ip)
Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported VM encoding MS936.
at 0x40268e17: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/./libgcj.so.3)
at 0x4025bcd2: java.lang.Exception.Exception(java.lang.String) (/usr/lib/./libgcj.so.3)
at 0x402fce64: java.sql.SQLException.SQLException(java.lang.String, java.lang.String, int) (/usr/lib/./libgcj.so.3)
at 0x402fce3d: java.sql.SQLException.SQLException(java.lang.String, java.lang.String) (/usr/lib/./libgcj.so.3)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
........(其余略)
linux上jdk是1.4.1
请问如何解决?