|
楼主 |
发表于 2018-11-29 11:08:04
|
显示全部楼层
我们在OPMProcedure.java里增加了:
public static void test() {
String driver = "net.sourceforge.jtds.jdbc.Driver";
String url = "JDBC:jtds:sqlserver://10.1.0.5:1433;instance=EIS_JZERP;databaseName=jzerp_724"; //"jdbc:sqlserver://localhost:1433;DatabaseName=jzerp_724";
String username = "sa";
String password = "jzsoft168!@#";
Connection conn = null;
try {
Class.forName(driver); //classLoader,加载对应驱动
conn = (Connection) DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
String sql = "select * from SA_OPPerson"; //?
try {
PreparedStatement pstmt = (PreparedStatement)conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
int col = rs.getMetaData().getColumnCount();
System.out.println("============================");
while (rs.next()) {
for (int i = 1; i <= col; i++) {
System.out.print(rs.getString(i) + "\t");
if ((i == 2) && (rs.getString(i).length() < 8)) {
System.out.print("\t");
}
}
System.out.println("");
}
System.out.println("============================");
} catch (SQLException e) {
e.printStackTrace();
}
}
看出现卡死的情况下通过JDBC能连接上SA_OPPerson表吧。
|
|