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

请问如何解决?
...全文
256 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
MarsZ 2003-10-15
  • 打赏
  • 举报
回复
MS936是gbk的别名。。应该是redhat9

当时刚刚试验在tomcat和weblogic上,把以上Test.java改成jsp运行就正常乐

岂有此理啊
mortal 2003-10-15
  • 打赏
  • 举报
回复
你的linux是哪个版本啊,他报错是Unsupported VM encoding MS936

编码不支持,不好办咯~

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧