【发布时间】:2012-01-23 10:09:36
【问题描述】:
案例 1: 我正在尝试使用
连接到位于远程服务器上的 sql-server 2005 数据库Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
connection = DriverManager.getConnection("jdbc:sqlserver://190.128.4.195/unicodedemo?user=ab&password=ab@Admin&useUnicode=true&characterEncoding=UTF-8");
当我执行时,我得到了以下异常:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 190.128.4.195/unicodedemo?user=ab&password=ab@Admin&useUnicode=true&characterEncoding=UTF-8, port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
案例2:但是当我尝试使用数据源名称时使用
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
connection = java.sql.DriverManager.getConnection("jdbc:odbc:unidemo","ab","ab@Admin");
数据成功插入,但在这种情况下,它没有显示插入的 Unicode 数据。它显示为?????。
谁能帮忙解决这个错误?当我在案例 1 中提交时,如何使用第二种情况(即使用 DSN)插入 Unicode 值。
谢谢..
【问题讨论】: