GeeCON Prague 2014*
The moose likes Object Relational Mapping and the fly likes Caused by: java.sql.SQLException: Closed Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Caused by: java.sql.SQLException: Closed Connection" Watch "Caused by: java.sql.SQLException: Closed Connection" New topic
Author

Caused by: java.sql.SQLException: Closed Connection

Jigs Gohil
Greenhorn

Joined: Jun 09, 2011
Posts: 6

Here is my Hibernate Configuration file....


1) Kindly tell me which other properties do i need to configure to avoid this Exceprion...which comes daily in the morning forcing me to restart the server(weblogic 10.3)....???

2) Do I need to configure it in the Hibernate.cfg... OR it is better to create a JNDI using weblogic console....???
Anantha Sharma
Ranch Hand

Joined: Sep 01, 2010
Posts: 43

its always best to have a connection pool (preferably from a data source).. hibernate is not very good at managing connections (especially in a production environment).

you can use c3p0 (jar files comes with hibernate) for connection pooling if you can't create a datasource.

also if both the above options are not fesiable then try reading the following.

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html (read section 3.4: optional configuration properties)

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/architecture.html#architecture-current-session
Jigs Gohil
Greenhorn

Joined: Jun 09, 2011
Posts: 6

Thanks Anantha...
I have created the DataSource in the weblogic...(Production Mode)
But after doing that I faced two Problems....
1) with CLOB data weblogic wrapped the result and returned it....so I have to typecast it with weblogic CLOB instead of sql CLOB...thus writing the App Server dependent code....
any alternative for this...?
2) I am having procedure doing following 2 things... i ) inserts data into Global Temporary Table (Oracle) ii) Opens a Cursor which fetches the data from the same table...
Now the problem is..When I am Using Hibernate Configuration for Connection Parameters .. the proc works absolutely fine i.e the cursor opens with correct data....
But when I use DataSource... the Proc doesn't return anything...i.e the cursor contains zero rows...

Any Idea what could the Problem....?
Anantha Sharma
Ranch Hand

Joined: Sep 01, 2010
Posts: 43

you need to map the content as string not as a clop in hibernate... the documentation (links) has a sample program which cases a CLOB into a string...

that is the solution..


regarding the hibernate connection configuration & datasource... you need to make sure that the transaction manger used with the datasource is the correct one...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Caused by: java.sql.SQLException: Closed Connection