Hallo,
we are using hiberante 2.1 with oracle 9i in a tomcat 4.1.29 environment.
I run in the following problem:
I use the jndi for the connection pooling for hibernate and reference this
in the hibernate properties:
Code:
hibernate.connection.datasource=java:comp/env/jdbc/webbox
#hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
#hibernate.connection.url=jdbc:oracle:thin:@20.21.22.23:1521:<sid>
#hibernate.connection.username=<username>
#hibernate.connection.password=<passwort>
#hibernate.connection.pool_size=30
#hibernate.show_sql=true
#
hibernate.dialect=net.sf.hibernate.dialect.Oracle9Dialect
#
In the server.xml, the jndi configuration is done:
Code:
<ResourceParams name="jdbc/webbox">
<parameter>
<name>validationQuery</name>
<value>select * from dual</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>password</name>
<value>thePasswort</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@20.21.22.23:1521:sid</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>username</name>
<value>theUser</value>
</parameter>
</ResourceParams>
This environment works for all select update insert , what ever, expect
if I try to insert or update a blob field.
I got a class cast exception
java.lang.ClassCastException
at oracle.jdbc.driver.OracleConnection.physicalConnectionWithin(OracleConnection.java:5041)
at oracle.sql.BLOB.createTemporary(BLOB.java:767)
at com.csc.webbox.btasks.kunde.ObjektBT.kalkulationsDateiSpeichern(ObjektBT.java:231)
at com.csc.webbox.btasks.kunde.ObjektBT.kalkSpeichern(ObjektBT.java:164)
at com.csc.webbox.btasks.kunde.ObjektBT.kalkulationSpeichern(ObjektBT.java:112)
at com.csc.webbox.presentation.kalkulator.actions.ObjektKalkulationAnlegenAction.doExecute(ObjektKalkulationAnlegenAction.java:82)
at com.csc.webbox.presentation.WebboxAction.execute(WebboxAction.java:67)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
The code which leads to this exception is:
Code:
/** not active code segment ***************
if(kd == null)
{
kd = new Kalkdatei();
byte [] dummyBuffer = new byte[32];
dummyBuffer = (new String("DummyBlob")).getBytes();
kd.setKalkulationid(kalk.getKalkulationid());
kd.setDatei(Hibernate.createBlob(dummyBuffer));
Persistence.save(kd);
newKD = true;
}
Persistence.flush();
Persistence.refresh(kd, LockMode.UPGRADE);
oracle.sql.BLOB blob = (oracle.sql.BLOB) kd.getDatei();
OutputStream out = blob.getBinaryOutputStream();
out.write(kalk.getData());
out.close();
Persistence.flush();
****** end inactiv code segment **/
oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(Persistence.connection(), false, oracle.sql.BLOB.DURATION_SESSION);
blob.open(oracle.sql.BLOB.MODE_READWRITE);
OutputStream out = blob.getBinaryOutputStream();
out.write(kalk.getData() );
out.flush();
out.close();
blob.close();
I have also tried the inactive code segement above, but the same problem, i got a class cast exception in the line
Quote:
oracle.sql.BLOB blob = (oracle.sql.BLOB) kd.getDatei();
Thats the bad news.
The good news is, if I replace the jndi connection pool with the hibernate connection pool (commented lines in the hibernate.properties) all both solution works fine.
What is wrong in the jndi solution in conjunction with oracle blobs ?
Thanks a lot
Jurgen