2012-01-23 2 views
2

사례 1 : 나는 SQLSERVER에 내가 실행하면유니 코드는 데이터 소스 이름을 사용하여 SQLSERVER와 JDBC 연결을 지원

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
     connection = DriverManager.getConnection("jdbc:sqlserver://190.128.4.195/unicodedemo?user=ab&[email protected]&useUnicode=true&characterEncoding=UTF-8"); 

을 사용하여 원격 서버에 위치해 있으며 2005 데이터베이스를 연결하려고, I

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 190.128.4.195/unicodedemo?user=ab&[email protected]&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 : 다음과 같은 예외가 있어요을하지만

,536를 사용하여 데이터 소스 이름을 사용하려고 할 때
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ; 
connection = java.sql.DriverManager.getConnection("jdbc:odbc:unidemo","ab","[email protected]"); 

데이터를 성공적으로 삽입 할 수 있지만이 경우 삽입 된 유니 코드 데이터가 표시되지 않습니다. 그것의 표시는 ?????입니다.

누구든지 오류를 해결할 수 있습니까? 사례 1에서 커밋 할 때 두 번째 경우 (예 : DSN 사용)를 사용하여 유니 코드 값을 삽입하는 방법은 무엇입니까?

감사합니다 ..

답변

2

사례 1 : 가 SQL Server에 대한 연결 URL의 형식이됩니다 :

jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]] 

당신은 아마

jdbc:sqlserver://190.128.4.195;databaseName=unicodedemo;user=ab;[email protected];useUnicode=true;characterEncoding=UTF-8 
에 연결 URL을 변경해야한다는 것을 의미한다
관련 문제