commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sananda Dasgupta <sanm...@gmail.com>
Subject Exception for DBCP Connection Pooling
Date Tue, 12 Jul 2011 08:48:12 GMT
Hi,

                I have written a jocl properties file as below:



                <object
class="org.apache.commons.dbcp.PoolableConnectionFactory"

*xmlns*="http://apache.org/xml/xmlns/jakarta/commons/jocl">



<!-- the first argument is the ConnectionFactory -->

       <object class="org.apache.commons.dbcp.DriverConnectionFactory">

              <object class="oracle.jdbc.driver.OracleDriver"/>

              <string value="jdbc:oracle:thin@localhost:XE"/>

              <object class="java.util.Properties" null="true"/>

                     <!--<string name="*username*" value="np_sig"/>

                     <string name="password" value="np_sig"/>-->

                     <!--<string *username*="np_sig"/>

                     <string password="np_sig"/>-->

                     <string value="np_main"/>

                     <string value="np_main"/>

              <!--</object>-->

       </object>

<!--the next argument is the ObjectPool -->

       <object class="org.apache.commons.pool.impl.GenericObjectPool">

              <object class="org.apache.commons.pool.PoolableObjectFactory"
null="true"/>

              <int value="10"/>

              <byte value="1"/>

              <long value="2000"/> <!--max wait -->

              <int value="8"/>

              <boolean value="false"/>

              <boolean value="false"/>

              <long value="10000"/>

              <int value="5/>

              <long value="5000

              <boolean value="true"/><!--test while idle -->

       </object>

       <!--<object
class="org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory"

              null="true"/>-->

       <!--the next argument is the KeyedObjectPoolFactory -->

       <object
class="org.apache.commons.pool.impl.StackKeyedObjectPoolFactory">

              <int value="5"/><!--max idle -->

       </object>

       <string value="" null="true"/>

       <boolean value="false"/><!-- default read only-->

       <boolean value="true"/><!--default auto commit-->

</object>



My code looks like this:

Connection conn = *null*;

              *try* {

                     Class.*forName*("org.apache.commons.dbcp.PoolingDriver"
);

                     *if*(*null* == System.*getProperty*(
"org.xml.sax.driver")){

                           System.*setProperty*("org.xml.sax.driver",
"org.apache.xerces.parsers.SAXParser");

                     }



                     conn = DriverManager.*getConnection*(
"jdbc:apache:commons:dbcp:/dbConnectionPooling");

              } *catch* (ClassNotFoundException e) {



                     e.printStackTrace();

              } *catch* (SQLException e) {



                     e.printStackTrace();

              }



This is the below exception which I am getting:



*java.sql.SQLException*: Could not parse configuration file

       at org.apache.commons.dbcp.PoolingDriver.getConnectionPool(*
PoolingDriver.java:119*)

       at org.apache.commons.dbcp.PoolingDriver.connect(*
PoolingDriver.java:175*)

       at java.sql.DriverManager.getConnection(Unknown Source)

       at java.sql.DriverManager.getConnection(Unknown Source)

       at
com.hp.np.lnpdb.connection.NPDBConnectionManager.getDBCPConnection(*
NPDBConnectionManager.java:30*)

       at com.hp.np.lnpdb.connection.NPDBConnectionManager.getDSConnection(*
NPDBConnectionManager.java:12*)

       at com.hp.np.lnpdb.connection.NPDBConnectionManager.main(*
NPDBConnectionManager.java:45*)

Caused by: *java.lang.NullPointerException*

       at org.apache.commons.jocl.JOCLContentHandler.endElement(*
JOCLContentHandler.java:527*)

       at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)

       at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
Source)

       at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)

       at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)

       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

       at org.apache.commons.jocl.JOCLContentHandler.parse(*
JOCLContentHandler.java:342*)

       at org.apache.commons.jocl.JOCLContentHandler.parse(*
JOCLContentHandler.java:271*)

       at org.apache.commons.dbcp.PoolingDriver.getConnectionPool(*
PoolingDriver.java:116*)

       ... 6 more

Caused by: *java.lang.NullPointerException*

       at org.apache.commons.jocl.ConstructorUtil.invokeConstructor(*
ConstructorUtil.java:94*)

       at
org.apache.commons.jocl.JOCLContentHandler$ConstructorDetails.createObject(*
JOCLContentHandler.java:794*)

       at org.apache.commons.jocl.JOCLContentHandler.endElement(*
JOCLContentHandler.java:499*)

       ... 17 more



Please let me know what I am missing….



Regards

Sanmca

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message