This discussion is archived
1 Reply Latest reply: Oct 8, 2012 8:22 AM by rp0428 RSS

java.sql.SQLException: Fail to construct descriptor: Invalid argume

Rajan.Panchal Newbie
Currently Being Moderated
Hi ,
I am getting below error while creating an array descriptor.
java.sql.SQLException: Fail to construct descriptor: Invalid arguments
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147)
     at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:144)
     at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:115)
     at com.cognizant.r2.dwrclasses.ProcedureCaller.callProcedure(ProcedureCaller.java:113)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:740)
     at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:744)
     at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:593)
     at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:90)
     at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:120)
     at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:141)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
     at com.oracle.determinations.web.platform.util.CharsetFilter.doFilter(CharsetFilter.java:46)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
     at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
     at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
     at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
     at java.lang.Thread.run(Unknown Source)


I am trying to create an array decriptor. Below is the code snippet to do the same.

conn = DBUtilities.getConnection(rb.getString("JNDITPXSRT"));
               appServer = rb.getString("APP_SERVER");
               if(appServer.equalsIgnoreCase("TOMCAT")){                   
               if (conn instanceof org.apache.commons.dbcp.DelegatingConnection) {
                              log.debug("detected apache commons dbcp datasource");
                              NativeConnection = ((org.apache.commons.dbcp.DelegatingConnection) conn).getInnermostDelegate();
          }                
          }else if(appServer.equalsIgnoreCase("WEBSPHERE")){                   
               NativeConnection = (Connection) WSJdbcUtil.getNativeConnection((WSJdbcConnection)conn);                          
          }
               
               //conn = ((org.apache.commons.dbcp.DelegatingConnection) conn).getInnermostDelegate();
               log.info("R2_XSR: Database connection obtained");               
                              
               log.debug("R2_XSR:Connected to Database - "+rb.getString("JNDITPXSRT"));
               for(int t =0; t<pArray.length;t++){
               log.debug("R2_XSR: ParamArray Values:"+pArray[t]);
          }
     ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("TP_STRING_ARRAY_TABLE", NativeConnection );
          ARRAY arrayToPass = new ARRAY( descriptor, NativeConnection, pArray);
          log.debug("R2_XSR: Parameter array passed to procedure:"+procedureName+" Array:"+pArray);
          
          OracleCallableStatement ps = (OracleCallableStatement)NativeConnection.prepareCall("{ call "+procedureName+"( ?, ?,?,? ) }");
          ps.setArray(1, arrayToPass );
          ps.setInt(2, pageNo);
          ps.setInt(3, rowsPerPage);
          ps.registerOutParameter(4, OracleTypes.CURSOR);
          ps.execute();           
DBUtilities.java

This file returns the connection object.
public static Connection getConnection(String jndiName) throws Exception {
     int maxtry = 2;
     int DBConnectTry = 0;
     while( DBConnectTry++ < maxtry){
          log.info("trying to connect:"+DBConnectTry);
try {
     if(appServer.equalsIgnoreCase("TOMCAT")){                  
          DataSource ds = (DataSource)envCtx.lookup(jndiName);
          log.debug("Returning connection object for "+appServer);
return ds.getConnection();
     }else if(appServer.equalsIgnoreCase("WEBSPHERE")){
          DataSource ds = (DataSource)initCtx.lookup(jndiName);
          log.debug("Returning connection object for "+appServer);
          return ds.getConnection();
     }
} catch (javax.naming.NamingException e) {
log.fatal("JNDI lookup failed for DataSource "+jndiName, e);
throw new RuntimeException(e);
} catch (SQLException e) {
log.fatal("Failed to get a connection from DataSource "+jndiName, e);
log.info("Wait for 1 sec...");
initCtx.close();
Long WaitTime = System.currentTimeMillis()+1000L;
while(System.currentTimeMillis()<WaitTime){
     
}
log.info("Wait Over retrying...");
}
     }
     return null;

}

Any idea why I am getting this error.
In context.xml , I have added this line too.

<Resource name="JNDI/TPXSRUDB" auth="Container" type="javax.sql.DataSource" accessToUnderlyingConnectionAllowed="true"
/>
  • 1. Re: java.sql.SQLException: Fail to construct descriptor: Invalid argume
    rp0428 Guru
    Currently Being Moderated
    >
    I am getting below error while creating an array descriptor.
    >
    And you say this is your code for doing that?
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("TP_STRING_ARRAY_TABLE", NativeConnection );
    ARRAY arrayToPass = new ARRAY( descriptor, NativeConnection, pArray);
    Why aren't you following the advice you were given in your other thread by dsurber, an Oracle JDBC developer?
    Re: Database connection not closed inspite of close statements
    >
    Don't call the ARRAY constructor directly. Use OracleConnection.createARRAY(String, Object[]) instead. This avoids having to unwrap the connection in order to pass it to the constructor. It does assume that the connection wrapper exposes Oracle specific methods.

    Calling the various constructors in oracle.sql is not good practice. It is strongly discouraged in 11 and will likely be desupported in some future release. Use the createFoo methods in Connection instead.
    >
    Reread that entire other thread and reply and try the advice given. If you have trouble implementing that advice then post the problems you are having.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points