myeclipce 怎么链接不上 db2 求解
报错信息error:A communication error has been detected. Communication protocol being used: Reply.fill(). Communication API being used: InputStream.read(). Location where the error was detected: insufficient data. Communication function detecting the error: *. Protocol specific error codes(s) TCP/IP SOCKETS DB2ConnectionCorrelator: null
java 链接数据库 测试 代码
public static void main(String[] args){
String driver = "com.ibm.db2.jcc.DB2Driver";
String url = "jdbc:db2://localhost:50000/cwswl";
String userName = "db2admin";
String passWord = "555555";
Connection conn = null;
Statement st = null;
ResultSet rs = null;
String sql = null;
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url,userName,passWord);
st = conn.createStatement();
sql = "select * from db2admin.registerdb";
rs = st.executeQuery(sql);
while(rs.next()){
System.out.println("连接成功");
System.out.println(rs.getString(1));
}
conn.close();
} catch (Exception e){
System.out.println("链接失败");
System.out.println("error:" + e.getMessage() );
//System.out.println(e.toString());
}
} --------------------编程问答-------------------- 沙发,请人来帮忙看看呀! --------------------编程问答-------------------- 没见过这错误 帮你查了 没查到。。。 --------------------编程问答-------------------- 参考这边吧...
http://bytes.com/topic/db2/answers/184909-problems-type-4-jdbc-driver
补充:Java , Web 开发