近期碰到了一个问题,就是在使用db2java.zip驱动连接db2数据库时,报错如下所示:
COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0615E 从套接字接收时出错,服务器不响应。SQLSTATE=08S01
at COM.ibm.db2.jdbc.net.SQLExceptionGenerator.throwReceiveError(SQLExceptionGenerator.java:507)
at COM.ibm.db2.jdbc.net.DB2Request.receive(DB2Request.java:727)
at COM.ibm.db2.jdbc.net.DB2Request.sendAndRecv(DB2Request.java:587)
at COM.ibm.db2.jdbc.net.DB2Connection.SQLConnect(DB2Connection.java:407)
at COM.ibm.db2.jdbc.net.DB2Connection.SQLConnect(DB2Connection.java:358)
at COM.ibm.db2.jdbc.net.DB2Connection.create(DB2Connection.java:343)
at COM.ibm.db2.jdbc.net.DB2Connection.<init>(DB2Connection.java:243)
at COM.ibm.db2.jdbc.net.DB2Driver.connect(DB2Driver.java:215)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at db2TestZip.main(db2TestZip.java:22)
查了一些资料后,自己碰到的问题在于需要在db2服务器端设置访问端口。需要执行命令db2jstrt 6789
后来更换了驱动,采用db2jcc.jar,填写正常的url等信息就可以正常访问了。
参考:
https://blog.csdn.net/amwayy/article/details/83192615
https://blog.csdn.net/weoln/article/details/4214028
https://jinyanliang.iteye.com/blog/1280707
https://blog.csdn.net/wkwanglei/article/details/6816527