HycelTaylor
asked on
Having trouble implementing a commons-DBCP JOCL configuration file as a resource
I'm trying to get my JOCL file to load as a resource using the command, conn = DriverManager.getConnectio n("jdbc:ap ache:commo ns:dbcp:/m axdb");.
I get the following exception:
java.sql.SQLException: No pool found for jdbc:apache:commons:dbcp:/ maxdb.
at org.apache.commons.dbcp.Po olingDrive r.connect( PoolingDri ver.java:1 44)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 512)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 193)
at com.tss.testadmin.service. JOCLPoolin gExample.m ain(JOCLPo olingExamp le.java:23 )
Allow me to elaborate:
I've created a JOCL file and placed it in my classes subdirectory under, C:\apps\classes\com\tss\te stadmin\re sources. The file, maxdb.jocl, is the following:
<object class="org.apache.commons. dbcp.Poola bleConnect ionFactory " xmlns="http://apache.org/xml/xmlns/jakarta/commons/jocl">
<!-- the first argument is the ConnectionFactory -->
<object class="org.apache.commons. dbcp.Drive rManagerCo nnectionFa ctory">
<string value="com.sap.dbtech.jdbc .DriverSap DB/jdbc:sa pdb:///ADM IN"/>
<object class="java.util.Propertie s" null="true"/>
</object>
<!-- the next argument is the ObjectPool -->
<object class="org.apache.commons. pool.impl. GenericObj ectPool">
<object class="org.apache.commons. pool.Poola bleObjectF actory" null="true"/>
<int value="10"/> <!-- max active -->
<byte value="1"/> <!-- when exhausted action, 0 = fail, 1 = block, 2 = grow -->
<long value="2000"/> <!-- max wait -->
<int value="10"/> <!-- max idle -->
<boolean value="false"/> <!-- test on borrow -->
<boolean value="false"/> <!-- test on return -->
<long value="10000"/> <!-- time between eviction runs -->
<int value="5"/> <!-- number of connections to test per eviction run -->
<long value="5000"/> <!-- min evictable idle time -->
<boolean value="true"/> <!-- test while idle -->
</object>
<!-- the next argument is the KeyedObjectPoolFactory -->
<object class="org.apache.commons. pool.Stack KeyedObjec tPoolFacto ry">
<int value="5"/> <!-- max idle -->
</object>
<string value="SELECT COUNT(*) FROM DUAL"/> <!-- validation query -->
<boolean value="false"/> <!-- default read only -->
<boolean value="true"/> <!-- default auto commit -->
</object>
I'm using the following source code in order to test my JOCL file:
package com.tss.testadmin.service;
import java.sql.*;
public class JOCLPoolingExample {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
try {
System.out.println("Load the maxdb driver and the pooling driver.");
Class.forName("com.sap.dbt ech.jdbc.D riverSapDB ");
Class.forName("org.apache. commons.db cp.Pooling Driver");
System.out.println("Creati ng connection.");
conn = DriverManager.getConnectio n("jdbc:ap ache:commo ns:dbcp:/m axdb");
System.out.println("Creati ng statement.");
stmt = conn.createStatement();
System.out.println("Execut ing statement.");
rset = stmt.executeQuery("SELECT * FROM DUAL");
System.out.println("Result s:");
int numcols = rset.getMetaData().getColu mnCount();
while (rset.next()) {
for (int i = 1; i <= numcols; i++) {
System.out.print("\t" + rset.getString(i));
}
System.out.println("");
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
rset.close();
} catch (Exception e) {
}
try {
stmt.close();
} catch (Exception e) {
}
try {
conn.close();
} catch (Exception e) {
}
}
}
}
According to the instructions at, http://jakarta.apache.org/commons/dbcp/apidocs/org/apache/commons/dbcp/package-summary.html#package_description, I think I have done every thing right. It states the following:
"Simply save that file somewhere in your classpath as eg.jocl, and the PoolingDriver will find it automatically. You need only register the PoolingDriver (for example, using the jdbc.drivers property), and use the the DriverManager to create your Connections, like you normally would:
Connection conn = DriverManager.getConnectio n("jdbc:ap ache:commo ns:dbcp:/e g");"
What I am doing wrong?
Thank, in advance.
I get the following exception:
java.sql.SQLException: No pool found for jdbc:apache:commons:dbcp:/
at org.apache.commons.dbcp.Po
at java.sql.DriverManager.get
at java.sql.DriverManager.get
at com.tss.testadmin.service.
Allow me to elaborate:
I've created a JOCL file and placed it in my classes subdirectory under, C:\apps\classes\com\tss\te
<object class="org.apache.commons.
<!-- the first argument is the ConnectionFactory -->
<object class="org.apache.commons.
<string value="com.sap.dbtech.jdbc
<object class="java.util.Propertie
</object>
<!-- the next argument is the ObjectPool -->
<object class="org.apache.commons.
<object class="org.apache.commons.
<int value="10"/> <!-- max active -->
<byte value="1"/> <!-- when exhausted action, 0 = fail, 1 = block, 2 = grow -->
<long value="2000"/> <!-- max wait -->
<int value="10"/> <!-- max idle -->
<boolean value="false"/> <!-- test on borrow -->
<boolean value="false"/> <!-- test on return -->
<long value="10000"/> <!-- time between eviction runs -->
<int value="5"/> <!-- number of connections to test per eviction run -->
<long value="5000"/> <!-- min evictable idle time -->
<boolean value="true"/> <!-- test while idle -->
</object>
<!-- the next argument is the KeyedObjectPoolFactory -->
<object class="org.apache.commons.
<int value="5"/> <!-- max idle -->
</object>
<string value="SELECT COUNT(*) FROM DUAL"/> <!-- validation query -->
<boolean value="false"/> <!-- default read only -->
<boolean value="true"/> <!-- default auto commit -->
</object>
I'm using the following source code in order to test my JOCL file:
package com.tss.testadmin.service;
import java.sql.*;
public class JOCLPoolingExample {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
try {
System.out.println("Load the maxdb driver and the pooling driver.");
Class.forName("com.sap.dbt
Class.forName("org.apache.
System.out.println("Creati
conn = DriverManager.getConnectio
System.out.println("Creati
stmt = conn.createStatement();
System.out.println("Execut
rset = stmt.executeQuery("SELECT * FROM DUAL");
System.out.println("Result
int numcols = rset.getMetaData().getColu
while (rset.next()) {
for (int i = 1; i <= numcols; i++) {
System.out.print("\t" + rset.getString(i));
}
System.out.println("");
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
rset.close();
} catch (Exception e) {
}
try {
stmt.close();
} catch (Exception e) {
}
try {
conn.close();
} catch (Exception e) {
}
}
}
}
According to the instructions at, http://jakarta.apache.org/commons/dbcp/apidocs/org/apache/commons/dbcp/package-summary.html#package_description, I think I have done every thing right. It states the following:
"Simply save that file somewhere in your classpath as eg.jocl, and the PoolingDriver will find it automatically. You need only register the PoolingDriver (for example, using the jdbc.drivers property), and use the the DriverManager to create your Connections, like you normally would:
Connection conn = DriverManager.getConnectio
What I am doing wrong?
Thank, in advance.
Do you have the maxdb.jocl file somewhere in your classpath?
ASKER
Yes,
If that means that it's in my classes subdirectory: c:\apps\classes\com\tss\te stadmin\re sources\ma xdb.jocl
At the beginning of my CLASSPATH variable I have: c:\apps\classes;
If that means that it's in my classes subdirectory: c:\apps\classes\com\tss\te
At the beginning of my CLASSPATH variable I have: c:\apps\classes;
From the link you posted:
>(Note that without the leading slash, the pool must be located at
>org/apache/commons/dbcp/P oolingDriv er/eg.jocl within your classpath. See Class.getResource(java.
>lang.String) for details.)
Can you put the maxdb.jocl in the org/apache/commons/dbcp/Po olingDrive r/ folder and try again? Otherwise put it inside the:
c:\apps\classes\com\tss\te stadmin\ma xdb.jocl (without the "resources" folder).
Try the above and tell me if they help.
>(Note that without the leading slash, the pool must be located at
>org/apache/commons/dbcp/P
>lang.String) for details.)
Can you put the maxdb.jocl in the org/apache/commons/dbcp/Po
c:\apps\classes\com\tss\te
Try the above and tell me if they help.
Or even in the:
c:\apps\classes\com\tss\te stadmin\se rvice\maxd b.jocl
c:\apps\classes\com\tss\te
ASKER
I've tried putting it in:
c:\apps\classes\com\tss\te stadmin\re sources\ma xdb.jocl
c:\apps\classes\com\tss\te stadmin\se rvice\maxd b.jocl
c:\apps\classes\com\tss\te stadmin\ma xdb.jocl
All to no avail.
I'm not sure if I tried your last suggestion correctly. I created the following subdirectory:
C:\apps\classes\org\apache \commons\d bcp\Poolin gDriver and placed maxdb.jocl in it.
It didn't work either. Is this what you meant?
c:\apps\classes\com\tss\te
c:\apps\classes\com\tss\te
c:\apps\classes\com\tss\te
All to no avail.
I'm not sure if I tried your last suggestion correctly. I created the following subdirectory:
C:\apps\classes\org\apache
It didn't work either. Is this what you meant?
Try putting it in the
c:\apps\classes\com\tss\te stadmin\se rvice\maxd b.jocl
and tell me if it works.
c:\apps\classes\com\tss\te
and tell me if it works.
Bah.. sorry ignore my above comment, you have already done so... Let me see what I can find.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please ignore this line:
> DriverManager.getConnectio n("jdbc:ap ache:commo ns:dbcp:/m axdb");.
of my comment above. I was just doing a comparison of the name.
> DriverManager.getConnectio
of my comment above. I was just doing a comparison of the name.
> You need only register the PoolingDriver (for example, using the jdbc.drivers property),
Have you done the above?
Have you done the above?
ASKER
Wonderful news! I tried placing it under c:\apps\classes and now I have a new exception:
org.apache.commons.dbcp.Db cpExceptio n: org.xml.sax.SAXException: System property org.xml.sax.driver not specified
at org.apache.commons.dbcp.Po olingDrive r.getPool( PoolingDri ver.java:1 10)
at org.apache.commons.dbcp.Po olingDrive r.connect( PoolingDri ver.java:1 42)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 512)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 193)
at com.tss.testadmin.service. JOCLPoolin gExample.m ain(JOCLPo olingExamp le.java:39 )
Caused by: org.xml.sax.SAXException: System property org.xml.sax.driver not specified
at org.xml.sax.helpers.XMLRea derFactory .createXML Reader(XML ReaderFact ory.java:9 0)
at org.apache.commons.jocl.JO CLContentH andler.par se(JOCLCon tentHandle r.java:377 )
at org.apache.commons.jocl.JO CLContentH andler.par se(JOCLCon tentHandle r.java:309 )
at org.apache.commons.dbcp.Po olingDrive r.getPool( PoolingDri ver.java:1 08)
... 4 more
Exception in thread "main"
But, this is progress:-)
I'm not sure what, System property org.xml.sax.driver not specified, means. Any ideas?
org.apache.commons.dbcp.Db
at org.apache.commons.dbcp.Po
at org.apache.commons.dbcp.Po
at java.sql.DriverManager.get
at java.sql.DriverManager.get
at com.tss.testadmin.service.
Caused by: org.xml.sax.SAXException: System property org.xml.sax.driver not specified
at org.xml.sax.helpers.XMLRea
at org.apache.commons.jocl.JO
at org.apache.commons.jocl.JO
at org.apache.commons.dbcp.Po
... 4 more
Exception in thread "main"
But, this is progress:-)
I'm not sure what, System property org.xml.sax.driver not specified, means. Any ideas?
Can you try adding these lines:
new PoolingDriver().registerPo ol("myPool ", new GenericObjectPool(null));
new PoolingDriver().registerPo
That's good news, I knew it was a classpath problem but I was not sure where exactly it should be. This confirms the saying that goes "if in doubt it's a classpath problem" :)
> System property org.xml.sax.driver not specified
You are obviously using a SAX parser. You need to specify the driver of the SAX pareser you are using, either in the command line -Dorg.xml.sax.driver=mycla ss.sax.myd river.Driv erClass or in the properties of your class by usign the System.getProeprties().put ("org.xml. sax.driver ", <value of your sax driver here>);
> System property org.xml.sax.driver not specified
You are obviously using a SAX parser. You need to specify the driver of the SAX pareser you are using, either in the command line -Dorg.xml.sax.driver=mycla
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Two questions:
1) Where exactly, in my code, do you want me to put the instruction?
2) Do you want me to use the words "myPool"? Or replace it with something else?
1) Where exactly, in my code, do you want me to put the instruction?
2) Do you want me to use the words "myPool"? Or replace it with something else?
Ignore the "myPool" thing, I just thought we coudl try it but it now works so this was never actually the problem.
Try to resolve the SAX issue. Which SAX parser are you using?
Try to resolve the SAX issue. Which SAX parser are you using?
ASKER
I am currently using the sax2.jar.
I was trying to follow the example at, http://cvs.apache.org/viewcvs.cgi/jakarta-commons/dbcp/doc/JOCLPoolingDriverExample.java?rev=1.4&view=markup. It says the following:
// To compile this example, you'll need nothing but the JDK (1.2+) in your classpath.
//
// To run this example, you'll want:
// * commons-collections.jar
// * commons-pool.jar
// * commons-dbcp.jar
// * the classes for your (underlying) JDBC driver
// * sax2.jar (the SAX 2 API)
// * a SAX2 friendly XML parser (jaxp.jar and parser.jar,
// for example)
// * the JOCL configuration for your database connection pool
// (poolingDriverExample.jocl , for example) in your classpath.
I looked every where to download, parser.jar, but couldn't find it.
I don't know if I need both.
I was trying to follow the example at, http://cvs.apache.org/viewcvs.cgi/jakarta-commons/dbcp/doc/JOCLPoolingDriverExample.java?rev=1.4&view=markup. It says the following:
// To compile this example, you'll need nothing but the JDK (1.2+) in your classpath.
//
// To run this example, you'll want:
// * commons-collections.jar
// * commons-pool.jar
// * commons-dbcp.jar
// * the classes for your (underlying) JDBC driver
// * sax2.jar (the SAX 2 API)
// * a SAX2 friendly XML parser (jaxp.jar and parser.jar,
// for example)
// * the JOCL configuration for your database connection pool
// (poolingDriverExample.jocl
I looked every where to download, parser.jar, but couldn't find it.
I don't know if I need both.
I think you might already have parser.jar. Do a search on your hard drive and tell me if you can find it.
ASKER
I think so. My search has found a parser.jar under c:\StrutsStudioPro\eclipse \plugins\o rg.apache. lucene_1.2 .1.
Does that sound like it?
Also, I have a crimson.jar. Isn't it also a sax2 friendl XML parser? And if it is, is there a reason for using one parser over another?
For crimson, I'm trying to figure out what to put for:
java -Dorg.xml.sax.driver=????
Does that sound like it?
Also, I have a crimson.jar. Isn't it also a sax2 friendl XML parser? And if it is, is there a reason for using one parser over another?
For crimson, I'm trying to figure out what to put for:
java -Dorg.xml.sax.driver=????
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's like pulling teeth.
I added the VM command, -Dorg.xml.sax.driver=org.a pache.crim son.parser .XMLReader Impl, and it worked. But then I got the following exception:
org.apache.commons.dbcp.Db cpExceptio n: java.lang.ClassNotFoundExc eption: org.apache.commons.pool.St ackKeyedOb jectPoolFa ctory
at org.apache.commons.dbcp.Po olingDrive r.getPool( PoolingDri ver.java:1 10)
at org.apache.commons.dbcp.Po olingDrive r.connect( PoolingDri ver.java:1 42)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 512)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 193)
at com.tss.testadmin.service. JOCLPoolin gExample.m ain(JOCLPo olingExamp le.java:40 )
at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
at sun.reflect.NativeMethodAc cessorImpl .invoke(Na tiveMethod AccessorIm pl.java:39 )
at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Delegati ngMethodAc cessorImpl .java:25)
at java.lang.reflect.Method.i nvoke(Meth od.java:32 4)
at com.intellij.rt.execution. applicatio n.AppMain. main(AppMa in.java:78 )
Caused by: java.lang.ClassNotFoundExc eption: org.apache.commons.pool.St ackKeyedOb jectPoolFa ctory
at org.apache.commons.jocl.JO CLContentH andler.sta rtElement( JOCLConten tHandler.j ava:514)
at org.apache.crimson.parser. Parser2.ma ybeElement (Parser2.j ava:1488)
at org.apache.crimson.parser. Parser2.co ntent(Pars er2.java:1 779)
at org.apache.crimson.parser. Parser2.ma ybeElement (Parser2.j ava:1507)
at org.apache.crimson.parser. Parser2.pa rseInterna l(Parser2. java:500)
at org.apache.crimson.parser. Parser2.pa rse(Parser 2.java:305 )
at org.apache.crimson.parser. XMLReaderI mpl.parse( XMLReaderI mpl.java:4 42)
at org.apache.commons.jocl.JO CLContentH andler.par se(JOCLCon tentHandle r.java:380 )
at org.apache.commons.jocl.JO CLContentH andler.par se(JOCLCon tentHandle r.java:309 )
at org.apache.commons.dbcp.Po olingDrive r.getPool( PoolingDri ver.java:1 08)
So, I checked the package and there is no class named: org.apache.commons.pool.St ackKeyedOb jectPoolFa ctory.
So, I checked the jocl config file that I copied from the example in the JOCL api documentation, and found the following:
<!-- the next argument is the KeyedObjectPoolFactory -->
<object class="org.apache.commons. pool.Stack KeyedObjec tPoolFacto ry">
<int value="5"/> <!-- max idle -->
</object>
So, I changed it to the following:
<!-- the next argument is the KeyedObjectPoolFactory -->
<object class="org.apache.commons. pool.Keyed ObjectPool Factory">
<int value="5"/> <!-- max idle -->
</object>
Apparently, this is not correct either. Now, I get the following exception:
org.apache.commons.dbcp.Db cpExceptio n: java.lang.NullPointerExcep tion
at org.apache.commons.dbcp.Po olingDrive r.getPool( PoolingDri ver.java:1 10)
at org.apache.commons.dbcp.Po olingDrive r.connect( PoolingDri ver.java:1 42)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 512)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 193)
at com.tss.testadmin.service. JOCLPoolin gExample.m ain(JOCLPo olingExamp le.java:39 )
at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
at sun.reflect.NativeMethodAc cessorImpl .invoke(Na tiveMethod AccessorIm pl.java:39 )
at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Delegati ngMethodAc cessorImpl .java:25)
at java.lang.reflect.Method.i nvoke(Meth od.java:32 4)
at com.intellij.rt.execution. applicatio n.AppMain. main(AppMa in.java:78 )
Caused by: java.lang.NullPointerExcep tion
at org.apache.commons.jocl.JO CLContentH andler.end Element(JO CLContentH andler.jav a:553)
at org.apache.crimson.parser. Parser2.ma ybeElement (Parser2.j ava:1528)
at org.apache.crimson.parser. Parser2.co ntent(Pars er2.java:1 779)
at org.apache.crimson.parser. Parser2.ma ybeElement (Parser2.j ava:1507)
at org.apache.crimson.parser. Parser2.pa rseInterna l(Parser2. java:500)
at org.apache.crimson.parser. Parser2.pa rse(Parser 2.java:305 )
at org.apache.crimson.parser. XMLReaderI mpl.parse( XMLReaderI mpl.java:4 42)
at org.apache.commons.jocl.JO CLContentH andler.par se(JOCLCon tentHandle r.java:380 )
at org.apache.commons.jocl.JO CLContentH andler.par se(JOCLCon tentHandle r.java:309 )
at org.apache.commons.dbcp.Po olingDrive r.getPool( PoolingDri ver.java:1 08)
It's progress. Any suggestions?
I added the VM command, -Dorg.xml.sax.driver=org.a
org.apache.commons.dbcp.Db
at org.apache.commons.dbcp.Po
at org.apache.commons.dbcp.Po
at java.sql.DriverManager.get
at java.sql.DriverManager.get
at com.tss.testadmin.service.
at sun.reflect.NativeMethodAc
at sun.reflect.NativeMethodAc
at sun.reflect.DelegatingMeth
at java.lang.reflect.Method.i
at com.intellij.rt.execution.
Caused by: java.lang.ClassNotFoundExc
at org.apache.commons.jocl.JO
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.commons.jocl.JO
at org.apache.commons.jocl.JO
at org.apache.commons.dbcp.Po
So, I checked the package and there is no class named: org.apache.commons.pool.St
So, I checked the jocl config file that I copied from the example in the JOCL api documentation, and found the following:
<!-- the next argument is the KeyedObjectPoolFactory -->
<object class="org.apache.commons.
<int value="5"/> <!-- max idle -->
</object>
So, I changed it to the following:
<!-- the next argument is the KeyedObjectPoolFactory -->
<object class="org.apache.commons.
<int value="5"/> <!-- max idle -->
</object>
Apparently, this is not correct either. Now, I get the following exception:
org.apache.commons.dbcp.Db
at org.apache.commons.dbcp.Po
at org.apache.commons.dbcp.Po
at java.sql.DriverManager.get
at java.sql.DriverManager.get
at com.tss.testadmin.service.
at sun.reflect.NativeMethodAc
at sun.reflect.NativeMethodAc
at sun.reflect.DelegatingMeth
at java.lang.reflect.Method.i
at com.intellij.rt.execution.
Caused by: java.lang.NullPointerExcep
at org.apache.commons.jocl.JO
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.crimson.parser.
at org.apache.commons.jocl.JO
at org.apache.commons.jocl.JO
at org.apache.commons.dbcp.Po
It's progress. Any suggestions?
> So, I checked the package and there is no class named: org.apache.commons.pool.St ackKeyedOb jectPoolFa ctory.
Can you make sure that you have *all* the needed files?
Can you make sure that you have *all* the needed files?
ASKER
I'm pretty sure I have all the files. There's not StackKeyedObjectPoolFactor y. I went to , http://cvs.apache.org/viewcvs.cgi/jakarta-commons/dbcp/doc/test.jocl?rev=1.2&view=markup, and replace my jocl schema with the one on this page. I tried using the following configuration document:
<object class="org.apache.commons. dbcp.Poola bleConnect ionFactory " xmlns="http://apache.org/xml/
xmlns/jakarta/commons/jocl ">
<object class="org.apache.commons. dbcp.Drive rConnectio nFactory">
<object class="com.sap.dbtech.jdbc .DriverSap DB"/>
<string value="jdbc:sapdb:///ESCO" />
<object class="java.util.Propertie s" null="true"/>
</object>
<object class="org.apache.commons. pool.impl. GenericObj ectPool">
<object class="org.apache.commons. pool.Poola bleObjectF actory" null="true"/>
<int value="10"/>
<byte value="1"/>
<long value="2000"/>
<int value="10"/>
<boolean value="true"/>
<boolean value="true"/>
<long value="10000"/>
<int value="5"/>
<long value="5000"/>
<boolean value="true"/>
</object>
<object class="org.apache.commons. pool.impl. GenericKey edObjectPo olFactory" >
<object class="org.apache.commons. pool.Keyed PoolableOb jectFactor y" null="true"/>
<int value="10"/>
<byte value="1"/>
<long value="2000"/>
<int value="10"/>
<boolean value="true"/>
<boolean value="true"/>
<long value="10000"/>
<int value="5"/>
<long value="5000"/>
<boolean value="true"/>
</object>
<string value="SELECT COUNT(*) FROM DUAL"/>
<boolean value="false"/>
<boolean value="true"/>
</object>
This gave the following exception:
java.lang.NullPointerExcep tion
at com.sap.dbtech.jdbc.Driver SapDB.open Trace(Driv erSapDB.ja va:206)
at com.sap.dbtech.jdbc.Driver SapDB.conn ect(Driver SapDB.java :173)
at org.apache.commons.dbcp.Dr iverConnec tionFactor y.createCo nnection(D riverConne ctionFacto ry.java:83 )
at org.apache.commons.dbcp.Po olableConn ectionFact ory.makeOb ject(Poola bleConnect ionFactory .java:184)
at org.apache.commons.pool.im pl.Generic ObjectPool .borrowObj ect(Generi cObjectPoo l.java:722 )
at org.apache.commons.dbcp.Po olingDrive r.connect( PoolingDri ver.java:1 47)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 512)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 193)
at com.tss.testadmin.service. JOCLPoolin gExample.m ain(JOCLPo olingExamp le.java:40 )
at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
at sun.reflect.NativeMethodAc cessorImpl .invoke(Na tiveMethod AccessorIm pl.java:39 )
at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Delegati ngMethodAc cessorImpl .java:25)
at java.lang.reflect.Method.i nvoke(Meth od.java:32 4)
at com.intellij.rt.execution. applicatio n.AppMain. main(AppMa in.java:78 )
Exception in thread "main"
So, I modified the configuration slightly from:
<object class="org.apache.commons. dbcp.Drive rConnectio nFactory">
<object class="com.sap.dbtech.jdbc .DriverSap DB"/>
<string value="jdbc:sapdb:///ESCO" />
<object class="java.util.Propertie s" null="true"/>
</object>
To:
<object class="org.apache.commons. dbcp.Drive rConnectio nFactory">
<object class="com.sap.dbtech.jdbc .DriverSap DB"/>
<string value="com.sap.dbtech.jdbc .DriverSap DB/jdbc:sa pdb:///ESC O"/>
<object class="java.util.Propertie s" null="true"/>
</object>
Now I'm getting the following exception:
java.lang.NullPointerExcep tion
at org.apache.commons.dbcp.De legatingCo nnection.s etAutoComm it(Delegat ingConnect ion.java:2 37)
at org.apache.commons.dbcp.De legatingCo nnection.s etAutoComm it(Delegat ingConnect ion.java:2 37)
at org.apache.commons.dbcp.Po olableConn ectionFact ory.activa teObject(P oolableCon nectionFac tory.java: 273)
at org.apache.commons.pool.im pl.Generic ObjectPool .borrowObj ect(Generi cObjectPoo l.java:753 )
at org.apache.commons.dbcp.Po olingDrive r.connect( PoolingDri ver.java:1 47)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 512)
at java.sql.DriverManager.get Connection (DriverMan ager.java: 193)
at com.tss.testadmin.service. JOCLPoolin gExample.m ain(JOCLPo olingExamp le.java:40 )
at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
at sun.reflect.NativeMethodAc cessorImpl .invoke(Na tiveMethod AccessorIm pl.java:39 )
at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Delegati ngMethodAc cessorImpl .java:25)
at java.lang.reflect.Method.i nvoke(Meth od.java:32 4)
at com.intellij.rt.execution. applicatio n.AppMain. main(AppMa in.java:78 )
Exception in thread "main"
I don't know if I'm getting warmer or not? Any suggestions?
<object class="org.apache.commons.
xmlns/jakarta/commons/jocl
<object class="org.apache.commons.
<object class="com.sap.dbtech.jdbc
<string value="jdbc:sapdb:///ESCO"
<object class="java.util.Propertie
</object>
<object class="org.apache.commons.
<object class="org.apache.commons.
<int value="10"/>
<byte value="1"/>
<long value="2000"/>
<int value="10"/>
<boolean value="true"/>
<boolean value="true"/>
<long value="10000"/>
<int value="5"/>
<long value="5000"/>
<boolean value="true"/>
</object>
<object class="org.apache.commons.
<object class="org.apache.commons.
<int value="10"/>
<byte value="1"/>
<long value="2000"/>
<int value="10"/>
<boolean value="true"/>
<boolean value="true"/>
<long value="10000"/>
<int value="5"/>
<long value="5000"/>
<boolean value="true"/>
</object>
<string value="SELECT COUNT(*) FROM DUAL"/>
<boolean value="false"/>
<boolean value="true"/>
</object>
This gave the following exception:
java.lang.NullPointerExcep
at com.sap.dbtech.jdbc.Driver
at com.sap.dbtech.jdbc.Driver
at org.apache.commons.dbcp.Dr
at org.apache.commons.dbcp.Po
at org.apache.commons.pool.im
at org.apache.commons.dbcp.Po
at java.sql.DriverManager.get
at java.sql.DriverManager.get
at com.tss.testadmin.service.
at sun.reflect.NativeMethodAc
at sun.reflect.NativeMethodAc
at sun.reflect.DelegatingMeth
at java.lang.reflect.Method.i
at com.intellij.rt.execution.
Exception in thread "main"
So, I modified the configuration slightly from:
<object class="org.apache.commons.
<object class="com.sap.dbtech.jdbc
<string value="jdbc:sapdb:///ESCO"
<object class="java.util.Propertie
</object>
To:
<object class="org.apache.commons.
<object class="com.sap.dbtech.jdbc
<string value="com.sap.dbtech.jdbc
<object class="java.util.Propertie
</object>
Now I'm getting the following exception:
java.lang.NullPointerExcep
at org.apache.commons.dbcp.De
at org.apache.commons.dbcp.De
at org.apache.commons.dbcp.Po
at org.apache.commons.pool.im
at org.apache.commons.dbcp.Po
at java.sql.DriverManager.get
at java.sql.DriverManager.get
at com.tss.testadmin.service.
at sun.reflect.NativeMethodAc
at sun.reflect.NativeMethodAc
at sun.reflect.DelegatingMeth
at java.lang.reflect.Method.i
at com.intellij.rt.execution.
Exception in thread "main"
I don't know if I'm getting warmer or not? Any suggestions?
ASKER
You know what? I'm beginning to think that using a JOCL file is just that, a Joke. I successfully tried the following set of code to get a connection:
try {
Class.forName("com.sap.dbt ech.jdbc.D riverSapDB ");
Class.forName("org.apache. commons.db cp.Pooling Driver");
GenericObjectPool connectionPool = new GenericObjectPool(null);
ConnectionFactory connectionFactory = new DriverManagerConnectionFac tory
("jdbc:sapdb:///ADMIN", "myuser", "mypassword");
PoolableConnectionFactory poolableConnectionFactory =
new PoolableConnectionFactory( connection Factory, connectionPool, null, null, false, true);
PoolingDataSource dataSource = new PoolingDataSource(connecti onPool);
Connection conn = dataSource.getConnection() ;
} catch (Exception e) {
e.printStackTrace();
}
With the time that it is taking to figure out how to use the JOCL resource correctly, I could use the commons-config to extract information from the config file and initialize the above classes myself; which is exactly what I'm gonna do.
Anyway, you answered the question that started all of this. That was how to find the resource in the class path. So, you've more than earned the 500 points and then some.
Thank you girionis, for all of your help today conserning this issue. I'm much obliged:-)
try {
Class.forName("com.sap.dbt
Class.forName("org.apache.
GenericObjectPool connectionPool = new GenericObjectPool(null);
ConnectionFactory connectionFactory = new DriverManagerConnectionFac
("jdbc:sapdb:///ADMIN", "myuser", "mypassword");
PoolableConnectionFactory poolableConnectionFactory =
new PoolableConnectionFactory(
PoolingDataSource dataSource = new PoolingDataSource(connecti
Connection conn = dataSource.getConnection()
} catch (Exception e) {
e.printStackTrace();
}
With the time that it is taking to figure out how to use the JOCL resource correctly, I could use the commons-config to extract information from the config file and initialize the above classes myself; which is exactly what I'm gonna do.
Anyway, you answered the question that started all of this. That was how to find the resource in the class path. So, you've more than earned the 500 points and then some.
Thank you girionis, for all of your help today conserning this issue. I'm much obliged:-)
> I don't know if I'm getting warmer or not? Any suggestions?
Same here. What is the line that throws the npe?
Same here. What is the line that throws the npe?
Also it would be good if you could try another parser.
Well, as long as you are happy with the solution and it works then go for it :)
Glad I was of help :)
Glad I was of help :)
ASKER
Just one more question conserning you suggestion about using another parser.
I tried using the Parser.jar, that I found on my harddrive, but it doesn't appear to the actual Parser. But some subset of it or simple another class, entirely, with the same name.
What parser would you suggest?
What about Xerces-J?
Irrespective of the one you suggest, how do you determine which is the right class to register. For example, with crimson, you knew to use java -Dorg.xml.sax.driver=org.a pache.crim son.parser .XMLReader Impl.
I tried using the Parser.jar, that I found on my harddrive, but it doesn't appear to the actual Parser. But some subset of it or simple another class, entirely, with the same name.
What parser would you suggest?
What about Xerces-J?
Irrespective of the one you suggest, how do you determine which is the right class to register. For example, with crimson, you knew to use java -Dorg.xml.sax.driver=org.a
Thank you for accepting :)
I use xerces-2 from the apache project: http://xml.apache.org/xerces2-j/
> Irrespective of the one you suggest, how do you determine which is the right class to register.
One of the classes in the jar file is the driver. You need to look at the docs to find out which one you have to use :)
I use xerces-2 from the apache project: http://xml.apache.org/xerces2-j/
> Irrespective of the one you suggest, how do you determine which is the right class to register.
One of the classes in the jar file is the driver. You need to look at the docs to find out which one you have to use :)