我无法在DB2中选择

时间:2011-10-24 12:19:35

标签: java jdbc db2

我有一个应用程序,包括:Spring,WebSphere,访问DB2 jdbc。 一切都设置好了,应用程序通常会发布,因为当我在任何一个桌子上选择一个座位时,我会收到以下错误。

OsjsSQLErrorCodeSQLExceptionTranslator DEBUG - Translating SQLException with SQL 
state '42Y07 ', error code '30000', message [Schema 'DBPROD' does not exist]; SQL was 
[SELECT * FROM DBPROD.EXPUR_CONS_CRIVO] for task [PreparedStatementCallback]
[10/24/11 10:11:54:257 EST] 0000001b SystemOut The 10:11:54.249 [WebContainer: 1] 
ERROR bcbwahdHistoricoDescontoDAOImpl - [requestID A8IUK52K =] 
HistoricoDescontoDAOImpl.consultarHistoricoDesconto Terminating with error ()
org.springframework.dao.DataAccessResourceFailureException: PreparedStatementCallback; 
SQL [SELECT * FROM DBPROD.EXPUR_CONS_CRIVO]; Schema 'DBPROD' does not exist; 
java.sql.SQLSyntaxErrorException nested exception is: Schema 'DBPROD' does not exist
at [spring-jdbc-3.0.1.RELEASE.jar: 3.0.1.RELEASE]
at [spring-jdbc-3.0.1.RELEASE.jar: 3.0.1.RELEASE]

Caused by: org.apache.derby.impl.jdbc.EmbedSQLException: Schema 'DBPROD' does not exist
    at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) [derby-10.5.3.0_1.jar:na]
    ... 191 common frames omitted
Caused by: org.apache.derby.iapi.error.StandardException: Schema 'DBPROD' does not exist
    at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) [derby-10.5.3.0_1.jar:na]
    at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source) [derby-10.5.3.0_1.jar:na]
    ... 185 common frames omitted

我的用户拥有对数据库的完全访问权限,因为我不知道该怎么做。

2 个答案:

答案 0 :(得分:0)

以'42'开头的SQL状态代码通常指的是语法错误,但在你的Case中,很明显缺少Schema。 检查这些链接希望它们可以帮助您解决这个问题:

  1. CURRENT SCHEMA special register

  2. how do i get the current schema on DB2 if i have a JDBC conneciton?

答案 1 :(得分:0)

如前所述,您获得的错误消息来自Apache Derby JDBC驱动程序。在WebSphere中配置应用程序时,请检查是否选择了正确的数据源。