-->
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.  [ 3 posts ] 
Author Message
 Post subject: C3P0Connection JDBC Connection Object
PostPosted: Tue Jun 01, 2004 10:28 am 
Newbie

Joined: Sun May 23, 2004 3:37 pm
Posts: 4
Hi,

I am using Hibernate v22branch and I was trying to access the JDBC connection object of a session. When I load hibernate I get this message:

INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)

I understand what this means: I am using no external connection pool manager. This is not the problem. When I use this I can get in my code the JDBC connection object like this:

Code:
( (PGConnection) session.connection() ).addDataType( "geometry", business.types.postgis.PGgeometry" );


Of course, this will only work if I use the PostgreSQL database dialect.

Well, the problem is when I started to use C3P0Connection provider. What is returned by the session.connection() method? Java throws a invalid typecast exception. This means that the JDBC connection is not a PGConnection anymore. Does anyone have experience on this?

Thanks,
Romano


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 11:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use your debugger to look at it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 5:43 pm 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
What you'll get here is the C3P0 Connection wrapper. To get the underlying Connection, you can for example call session.connection().getMetaData().getConnection(), which will give you the native Connection that can safely be cast to the driver implementation (like OracleConnection or PGConnection).

Unfortunately, the exact strategy to do this is specific to the connection pool. So if you don't want to tie your code to a specific connection pool, use some sort of abstraction. <plug>Spring includes such an abstraction in the form of the NativeJdbcExtractor interface, with various out-of-the-box implementations.</plug>

Juergen
http://www.springframework.org


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.