SQL Server 2008에 로컬로 연결하면 로컬 컴퓨터에서 개발할 때이 기능이 정상적으로 작동하지만 프로덕션 환경에서만 중단됩니다. 실행됩니다 코드의 그SQL Server 2008 R2에서 응답없이 JDBC 연결이 끊어집니다.
package oata;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import sun.applet.Main;
public class Sql {
public static final String SQLDRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
protected Connection conn = null;
private String ip = "";
private int port = 0;
private String databaseName = "";
private String db_userid = "";
private String db_password = "";
public void callDb(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{
System.out.println("Initialising variables");
ip = args[0];
port = Integer.parseInt(args[1]);
databaseName = args[2];
db_userid = args[3];
db_password = args[4];
try{
Log logger = LogFactory.getLog(Main.class);
System.out.println("Opening logger...");
logger.debug("opening driver " + SQLDRIVER);
System.out.println("Creating connection instance...");
Class.forName(SQLDRIVER).newInstance();
System.out.println("Driver Manager.getConnection...");
conn = DriverManager.getConnection(getDBURL(), db_userid, db_password);
System.out.println("Connection prepare statement...");
PreparedStatement ps = conn.prepareStatement("select * from nstupersonal");
System.out.println("Executing query...");
ResultSet rs = ps.executeQuery();
while(rs.next()){
System.out.println(rs.getString("StudentId"));
}
}catch(Exception e){
System.out.println(e.getMessage());
}
conn.close();
}
private String getDBURL(){
String url = "";
try {
url = "jdbc:sqlserver://" + ip
+":" + port +";databaseName="+
databaseName + ";user=" + db_userid + ";password="+db_password;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return url;
}
}
: 여기
는 코드입니다. 콘솔에서는 글자 그대로 프로덕션에 매달려 있습니다. 항상 SQL Server 2008에 매달려 있지만 다른 모든 고객을 위해 제대로 작동합니다. sim30ly와 함께 실행됩니다.SQL Server의 1433에서 TCP/IP가 사용되며 관리 콘솔에서 원격 연결이 true로 설정됩니다. 포트 DBNAME 사용자 암호
어떤 아이디어를 IPADDRESS -jar
자바? SQL 드라이버가 잘못 되었습니까? 나는 sqljdbc4.jar
결과 명령 프롬프트는 ...
초기화 중 변수 열기 로거 ... 드라이버 Manager.getConnection ... 어떤 예외가 발생하지 도착
을 사용하고
감사합니다,
D
어디이 중단합니까? 더 많은 로깅 구문을 삽입하여 줄을 매기는 줄을 추적 할 수 있습니까? – beny23
System out 및 throw 메시지를 포함하도록 코드가 업데이트되었지만 예외가 발생하지 않습니다. – david99world