-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: C3PO: native JDBC connection
PostPosted: Tue Aug 17, 2004 7:30 am 
Beginner
Beginner

Joined: Fri Aug 29, 2003 4:26 am
Posts: 26
Location: Germany, Dortmund
Hi,

is it possible to retrieve the underlying JDBC connection from a connection which is provided by C3PO?

For DBCP I know:

Code:
          if( conn instanceof PoolableConnection) {
            PoolableConnection pconn = (PoolableConnection) conn;
            conn = pconn.getInnermostDelegate();
            if (OracleConnection.class.isAssignableFrom(conn.getClass())) {
              OracleConnection oracleCon = (OracleConnection) conn;
              // do nasty Oracle stuff
            }
          }

_________________
Bye
Kai


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 7:31 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
session.connection();

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 7:38 am 
Beginner
Beginner

Joined: Fri Aug 29, 2003 4:26 am
Posts: 26
Location: Germany, Dortmund
Unfortunately not.

session.connection() returns a JDBC connection, but not the Oracle JDBC connection if you are working with C3PO.
I need the Oracle JDBC-Connection because of the nasty Blob-Handling (refer http://www.hibernate.org/56.html which shows a little bit ugly solution)

_________________
Bye
Kai


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 7:39 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The DataDirect JDBC driver for Oracle is much better if you have lots of LOBs, it supports real JDBC LOB handling.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 8:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
There should be a way to get the real connection from the wrapped c3p0 connection - read the c3p0 api


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 11:39 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
An easy way that works with most connection pools is the following:

Code:
Connection nativeCon = session.connection().getMetaData().getConnection();


Hardly any pool cares to wrap the DatabaseMetaData connection. I've recently checked that this works for C3P0.

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 12:05 pm 
Beginner
Beginner

Joined: Fri Aug 29, 2003 4:26 am
Posts: 26
Location: Germany, Dortmund
Thanks Juergen, this works fine for me.

_________________
Bye
Kai


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 3:52 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
I try this code

session.connection().getMetaData().getConnection() with c3p0 this return
not a real connection but an instance of NewProxyConnetion

i'm using the last version of c3p0.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 27, 2005 5:52 am 
Beginner
Beginner

Joined: Fri Aug 29, 2003 4:26 am
Posts: 26
Location: Germany, Dortmund
I am currently using DBCP because of problems with c3p0 (some statements hanging).
With DBCP it works fine, but thank you for your posting, so I be careful with changing to a newer c3p0 version.

_________________
Bye
Kai


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 27, 2005 8:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
For Oracle-Blob handling with c3p0 look here: http://www.mchange.com/projects/c3p0/in ... appendix_c

For all other non-standard methods look here: http://www.mchange.com/projects/c3p0/in ... ection_ops


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.