db2连接数据库异常"com.ibm.db2.jcc.c.DisconnectException"

最近没事搞搞db2的数据,首先安装。下载了一个数据库的客户端。squirrel-sql这个客户端还是比较好用的。是一个免费的客户端。地址我就不贴了。

好了,进入正题。

 

db2和squirrel-sql都安装好之后,遇到一个让我郁闷了两天的问题。在用客户端连接db2数据库的时候出现异常。异常信息是:

com.ibm.db2.jcc.c.DisconnectException: [ibm][db2][jcc][t4][2030][11211] A communication error has been detected. Communication protocol being used: TCP/IP.
Communication API being used: SOCKETS.  Location where the error was detected: Reply.fill().
Communication function detecting the error: InputStream.read().  Protocol specific error codes Insufficient data, * , 0.  Message: null
	at com.ibm.db2.jcc.a.a.a(a.java:366)
	at com.ibm.db2.jcc.a.ab.b(ab.java:219)
	at com.ibm.db2.jcc.a.ab.c(ab.java:237)
	at com.ibm.db2.jcc.a.ab.c(ab.java:348)
	at com.ibm.db2.jcc.a.ab.v(ab.java:1134)
	at com.ibm.db2.jcc.a.bb.a(bb.java:42)
	at com.ibm.db2.jcc.a.b.j(b.java:1254)
	at com.ibm.db2.jcc.a.b.b(b.java:1128)
	at com.ibm.db2.jcc.a.b.b(b.java:711)
	at com.ibm.db2.jcc.a.b.a(b.java:697)
	at com.ibm.db2.jcc.a.b.a(b.java:378)
	at com.ibm.db2.jcc.a.b.<init>(b.java:316)
	at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:174)
	at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:133)
	at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.execute(OpenConnectionCommand.java:97)
	at net.sourceforge.squirrel_sql.client.mainframe.action.ConnectToAliasCommand$SheetHandler.run(ConnectToAliasCommand.java:281)
	at net.sourceforge.squirrel_sql.client.mainframe.action.ConnectToAliasCommand$SheetHandler.performOK(ConnectToAliasCommand.java:238)
	at net.sourceforge.squirrel_sql.client.gui.db.ConnectionInternalFrame.connect(ConnectionInternalFrame.java:311)
	at net.sourceforge.squirrel_sql.client.gui.db.ConnectionInternalFrame.access$300(ConnectionInternalFrame.java:56)
	at net.sourceforge.squirrel_sql.client.gui.db.ConnectionInternalFrame$MyOkClosePanelListener.okPressed(ConnectionInternalFrame.java:461)
	at net.sourceforge.squirrel_sql.client.gui.OkClosePanel.fireButtonPressed(OkClosePanel.java:148)
	at net.sourceforge.squirrel_sql.client.gui.OkClosePanel.access$100(OkClosePanel.java:33)
	at net.sourceforge.squirrel_sql.client.gui.OkClosePanel$1.actionPerformed(OkClosePanel.java:174)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$200(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at net.sourceforge.squirrel_sql.client.Main$1.dispatchEvent(Main.java:93)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

 当时我就郁闷了,带着沉重的心情上了百度、谷歌,实验了n种方法,最终没能解决这个问题。

后来发怒了,我写了一个jdbc连接数据库,出现另外一个问题:

连接失败!
com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2030][11211][4.16.53] 在对连接的底层 socket、socket input stream 或 socket output stream 执行操作期间
发生通信错误。错误位置:Reply.fill() - insufficient data (-1)。消息:数据不足。 ERRORCODE=-4499, SQLSTATE=08001
	at com.ibm.db2.jcc.am.fd.a(fd.java:320)
	at com.ibm.db2.jcc.t4.a.a(a.java:526)
	at com.ibm.db2.jcc.t4.a.a(a.java:510)
	at com.ibm.db2.jcc.t4.a.a(a.java:505)
	at com.ibm.db2.jcc.t4.x.b(x.java:294)
	at com.ibm.db2.jcc.t4.x.c(x.java:320)
	at com.ibm.db2.jcc.t4.x.c(x.java:433)
	at com.ibm.db2.jcc.t4.x.v(x.java:1201)
	at com.ibm.db2.jcc.t4.y.a(y.java:51)
	at com.ibm.db2.jcc.t4.b.c(b.java:1353)
	at com.ibm.db2.jcc.t4.b.b(b.java:1225)
	at com.ibm.db2.jcc.t4.b.b(b.java:793)
	at com.ibm.db2.jcc.t4.b.a(b.java:765)
	at com.ibm.db2.jcc.t4.b.a(b.java:423)
	at com.ibm.db2.jcc.t4.b.a(b.java:398)
	at com.ibm.db2.jcc.t4.b.<init>(b.java:336)
	at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:233)
	at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:199)
	at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:474)
	at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:115)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:185)
	at com.DBconn.DBconnect.getConnection(DBconnect.java:36)
	at com.DBconn.DBconnect.main(DBconnect.java:49)
Exception in thread "main" java.lang.NullPointerException
	at com.DBconn.DBconnect.main(DBconnect.java:51)

 这就让我更加的郁闷了。一个错误还没有解决,新的错误又来了。然后我就死马当活马医。一个个用户名、密码实验,一个个ip实现。黄天不负有心人,最后让我试出来了。不过我也吐血了。

我丢:竟然最终原因就是ip有问题。不能用127.0.01、localhost访问。最终我改成本机的ip后,解决了。我也吐血了。

 

推荐一个db2的配置:http://publib.boulder.ibm.com/tividd/td/ITMFTP/GC23-4801-00/zh_CN/HTML/WTPImst30.htm

配置查询:http://iamwave.iteye.com/blog/649730
db
2数据库的学习中心:http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp

 

你可能感兴趣的:(db2)