Details
Description
To activate connection pooling using the Oracle JDBC driver, one has to use
the "data-source" form of configuration. This is a correct example for a
database configuration:
<database name="database" engine="oracle">
<data-source class-name="oracle.jdbc.pool.OracleConnectionCacheImpl">
<params URL="jdbc:oracle:thin:@localhost:1521:TEST" user="scott"
password="tiger" />
</data-source>
...
</database>
This activates Oracle connection pooling using the default parameters.
Optionally you can add additional parameters in <params> such as:
cache-time-to-live-timeout="30"
cache-fixed-wait-timeout="30"
max-limit="10"
What doesn't work is to specify an caching scheme using:
cache-scheme="OracleConnectionCacheImpl.DYNAMIC_SCHEME"
This results in an exception: (using Castor 0.9.5.3)
java.lang.NumberFormatException: For input
string: "OracleConnectionCacheImpl.FIXED_SCHEME"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.<init>(Unknown Source)
at org.exolab.castor.xml.UnmarshalHandler.toPrimitiveObject
(UnmarshalHandler.java:3303)
at org.exolab.castor.xml.UnmarshalHandler.processAttribute
(UnmarshalHandler.java:2770)
at org.exolab.castor.xml.UnmarshalHandler.processAttributes
(UnmarshalHandler.java:2479)
at org.exolab.castor.xml.UnmarshalHandler.startElement
(UnmarshalHandler.java:2147)
at org.exolab.castor.xml.UnmarshalHandler.startElement
(UnmarshalHandler.java:1292)
at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
at org.apache.xerces.validators.common.XMLValidator.callStartElement
(XMLValidator.java:1197)
at org.apache.xerces.framework.XMLDocumentScanner.scanElement
(XMLDocumentScanner.java:1862)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch
(XMLDocumentScanner.java:1238)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome
(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1035)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:605)
at org.exolab.castor.jdo.engine.DatabaseRegistry.loadDatabase
(DatabaseRegistry.java:235)
at org.exolab.castor.jdo.JDO.getDatabase(JDO.java:603)
at ScottTest.run(ScottTest.java:63)
at ScottTest.main(ScottTest.java:23)
It seems, Castor doesn't translate the expression constant into a numeric value.
The following option to specify a caching scheme doesn't work either:
cache-scheme="1"
This results in another exception:
java.lang.IllegalArgumentException: Type conversion error: could not set value
of cacheScheme(java.lang.Integer) with value of type java.lang.Integer
at org.exolab.castor.mapping.loader.FieldHandlerImpl.setValue
(FieldHandlerImpl.java:474)
at org.exolab.castor.xml.UnmarshalHandler.processAttribute
(UnmarshalHandler.java:2779)
at org.exolab.castor.xml.UnmarshalHandler.processAttributes
(UnmarshalHandler.java:2479)
at org.exolab.castor.xml.UnmarshalHandler.startElement
(UnmarshalHandler.java:2147)
at org.exolab.castor.xml.UnmarshalHandler.startElement
(UnmarshalHandler.java:1292)
at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
at org.apache.xerces.validators.common.XMLValidator.callStartElement
(XMLValidator.java:1197)
at org.apache.xerces.framework.XMLDocumentScanner.scanElement
(XMLDocumentScanner.java:1862)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch
(XMLDocumentScanner.java:1238)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome
(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1035)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:605)
at org.exolab.castor.jdo.engine.DatabaseRegistry.loadDatabase
(DatabaseRegistry.java:235)
at org.exolab.castor.jdo.JDO.getDatabase(JDO.java:603)
at ScottTest.run(ScottTest.java:63)
at ScottTest.main(ScottTest.java:23)
This error occures, because the function setCacheScheme() excpects a 'long'
parameter, not a parameter of type 'int'. And Castor doesn't convert it from
java.lang.Integer to long.
Issue Links
- is depended upon by
-
CASTOR-1125
Castor XML/GSC_Regression: Map/Hashtable direct methods create an AnyNode instead of a MapItem/Testable on direct and get/set operations
-
-
CASTOR-1121
Castor XML/GSC_Regression: setter on a boolean is not called when a set-method is present.
-
-
CASTOR-1124
Castor XML/GSC_Regression: Add methods are simply not called.
-
- relates to
-
CASTOR-1147
CTF test case TC28 (jdo.Collections) fails when set-method points to a "addItem" method.
-
-
CASTOR-943
Create a test case for bug 1785 (JDO DataSource configuration using a Properties collection)
-
Martin, the second exception reported above definitely is genuine, and needs to
be addressed.
Please bear in mind that you won't be able to use an expression such as
cache-scheme="OracleConnectionCacheImpl.DYNAMIC_SCHEME"
at all, as we won't be able to access driver specific constants.