Search code examples
db2ibm-mobilefirstmobilefirst-adapters

DB2 exception: Cannot create PoolableConnectionFactory SQLCODE=-142,


I keep having the following error in MobileFirst Platform 6.3:

Runtime: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (DB2 SQL Error: SQLCODE=-142, SQLSTATE=42612, SQLERRMC=null, DRIVER=4.19.26)

This is my adapter code:

     var test2 = WL.Server.createSQLStatement("SELECT * FROM WSDIWC.WBPTRR1");

     function getCEID(cnum) {   
        return WL.Server.invokeSQLStatement({
            preparedStatement : test2,
            parameters : []
        });
     }

And adapter XML:

     <connectivity>
        <connectionPolicy xsi:type="sql:SQLConnectionPolicy">
        <!-- Example for using a JNDI data source, replace with actual data source 
            name -->
        <!-- <dataSourceJNDIName>${training-jndi-name}</dataSourceJNDIName> -->

        <!-- Example for using MySQL connector, do not forget to put the MySQL 
            connector library in the project's lib folder -->
         <dataSourceDefinition>
              <driverClass>com.ibm.db2.jcc.DB2Driver</driverClass>
               <url>jdbc:db2://***</url>
               <user>**</user>
                <password>**</password>
            </dataSourceDefinition>
        </connectionPolicy>
    </connectivity>

I have remove the url, user and password. Hope you help me out on clarification about the current problem.

I already know that the sql is not accepted since it's just a simple query.
I have also research about z/OS DB2 that it has issue with same error code sqlcode=-142. http://answers.splunk.com/answers/117024/splunk-db-connect-db2.html


Solution

  • While you say that this is a "simple query", the exception error code mentions the following:

    -142
    THE SQL STATEMENT IS NOT SUPPORTED

    Explanation

    An SQL statement was detected that is not supported by the database. The statement might be valid for other IBM® relational database products or it might be valid in another context. For example, statements such as VALUES and SIGNAL or RESIGNAL SQLSTATE can be used only in certain contexts, such as in a trigger body or in an SQL Procedure.

    System action
    The statement cannot be processed.

    Programmer response
    Change the syntax of the SQL statement or remove the statement from the program.

    You should review the DB2 SQL guidelines for how to achieve what you want to achieve, and also explain that in the question if you'd like further assistance. For example, are you sure "WSDIWC.WBPTRR1" is actually available?