-3
我有服務器中的數據庫DB2 SAMPLE 10.74.44.65:51020 我試圖連接到數據庫中的人員表但我有一個例外。 我使用IBM的db2jcc4。DB2 SQL錯誤:SQLCODE = -204,SQLSTATE = 42704,SQLERRMC = DB2ADMIN.STAFF,DRIVER = 4.22.29
Connection successfully
Test 1
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.STAFF, DRIVER=4.22.29
at com.ibm.db2.jcc.am.ld.a(ld.java:810)
at com.ibm.db2.jcc.am.ld.a(ld.java:66)
at com.ibm.db2.jcc.am.ld.a(ld.java:140)
at com.ibm.db2.jcc.am.up.c(up.java:2796)
at com.ibm.db2.jcc.am.up.d(up.java:2784)
at com.ibm.db2.jcc.am.up.a(up.java:2212)
at com.ibm.db2.jcc.t4.bb.i(bb.java:148)
at com.ibm.db2.jcc.t4.bb.b(bb.java:41)
at com.ibm.db2.jcc.t4.p.a(p.java:32)
at com.ibm.db2.jcc.t4.vb.i(vb.java:145)
at com.ibm.db2.jcc.am.up.lb(up.java:2181)
at com.ibm.db2.jcc.am.up.a(up.java:3300)
at com.ibm.db2.jcc.am.up.a(up.java:717)
at com.ibm.db2.jcc.am.up.executeQuery(up.java:696)
at Main.main(Main.java:24)
我的Java代碼。 10.74.44.65是服務器的位置ip。 數據庫連接,但我不能執行sql查詢。
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Main {
public static void main(String[] argv) {
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
}
catch (ClassNotFoundException e) {
e.printStackTrace();
return;
}
Connection conn;
Statement stmt;
ResultSet rs;
try {
conn = DriverManager.getConnection("jdbc:db2://10.74.44.65:51020/SAMPLE","db2admin","Us3admin");
System.out.println("Connection successfully");
stmt=conn.createStatement();
System.out.println("Test 1");
rs=stmt.executeQuery("select * from staff");
System.out.println("Test 2");
while (rs.next()) {
System.out.println("Employee number = " + rs.getString(1));
}
} catch (SQLException e) {
e.printStackTrace();
return;
}
}
}
我試過,但仍然錯誤:( –