关于db2的SQLCODE: -1031, SQLSTATE: 58031怎么解决啊?

时间:2021-12-06 09:00:14
我用java的jcc链接远程的数据库
用app的方式可以连上,但是用jcc连不上
错误如下:
Exception in thread "main" com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -1031, SQLSTATE: 58031, SQLERRMC: null
at com.ibm.db2.jcc.b.o.a(o.java:3219)
at com.ibm.db2.jcc.a.bb.q(bb.java:653)
at com.ibm.db2.jcc.a.bb.n(bb.java:494)
at com.ibm.db2.jcc.a.bb.a(bb.java:306)
at com.ibm.db2.jcc.a.bb.a(bb.java:111)
at com.ibm.db2.jcc.a.b.e(b.java:1233)
at com.ibm.db2.jcc.a.b.b(b.java:1147)
at com.ibm.db2.jcc.a.b.q(b.java:931)
at com.ibm.db2.jcc.a.b.a(b.java:702)
at com.ibm.db2.jcc.a.b.<init>(b.java:305)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:162)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at test.DBTest.getDB2Conn(DBTest.java:170)
at test.DBTest.testdb2(DBTest.java:36)
at test.DBTest.main(DBTest.java:31)
这个怎么解决呢?

6 个解决方案

#1


是这个数据库的jcc吗? 确认版本,lincence包也要放到classpath里

#2


当然是了,我分析的原因就是db2的数据库不是按照默认路径建的,所以jcc找不到,该怎么弄啊?

#3


SQL1031N The database directory cannot be found on the indicated
          file system.

Explanation:

The system database directory or local database directory could
not be found.  A database has not been created or it was not
cataloged correctly.

 The command cannot be processed.

User Response:

Verify that the database is created with the correct path
specification.  The Catalog Database command has a path parameter
which specifies the directory where the database resides.

 sqlcode :  -1031

 sqlstate :  58031

#4


我知道原因啊,到底该怎么解决呢?
数据库建立的目录不是默认目录,一个数据库在c判,一个在d盘
我本机又没装db2,如果装了db2用type2连是可以的
用type4练就不行了,找不到目录啊,怎么办?

#5


it doesn't matter where the phyiscal location of database, as long as it's properly cataloged on the server.

when you said "如果装了db2用type2连是可以的", are you sure you got correct connection string at client side?

#6


我sure呀,app方式就可以连啊,别得数据库都行啊,就是那个新建的数据库不行,jcc连的话就报那个错,那个错看说明的话不是找不到数据库么,为什么会找不到呢?

#1


是这个数据库的jcc吗? 确认版本,lincence包也要放到classpath里

#2


当然是了,我分析的原因就是db2的数据库不是按照默认路径建的,所以jcc找不到,该怎么弄啊?

#3


SQL1031N The database directory cannot be found on the indicated
          file system.

Explanation:

The system database directory or local database directory could
not be found.  A database has not been created or it was not
cataloged correctly.

 The command cannot be processed.

User Response:

Verify that the database is created with the correct path
specification.  The Catalog Database command has a path parameter
which specifies the directory where the database resides.

 sqlcode :  -1031

 sqlstate :  58031

#4


我知道原因啊,到底该怎么解决呢?
数据库建立的目录不是默认目录,一个数据库在c判,一个在d盘
我本机又没装db2,如果装了db2用type2连是可以的
用type4练就不行了,找不到目录啊,怎么办?

#5


it doesn't matter where the phyiscal location of database, as long as it's properly cataloged on the server.

when you said "如果装了db2用type2连是可以的", are you sure you got correct connection string at client side?

#6


我sure呀,app方式就可以连啊,别得数据库都行啊,就是那个新建的数据库不行,jcc连的话就报那个错,那个错看说明的话不是找不到数据库么,为什么会找不到呢?