> private Connection getConnection();
> private Session getHibernateSession()
> {
> Session s = null;
> try
> {
> Datastore ds =
> Hibernate.createDatastore();
> ds =
> ds.storeFile("/home/son/mapping.xml");
> SessionFactory sessionFactory =
> ds.buildSessionFactory();
> Connection conn = getConnection();
> s = sessionFactory.openSession(conn);
> }
> catch (Exception ex)
> {
> ex.printStackTrace();
> }
> return s;
> }
>
> ----end---
> The EJB container I'm using is JBoss2.4.4 and the
> database is postgresql7.1
[...]
> This happens when I connect to the bean 32 times. It
> seems hibernate is not releasing the Connection even
> though I did a session.close(). When I try to connect
> to postgres directly using JDBC, I get
>
> Exception: java.sql.SQLException: Sorry, too many
> clients already
>
It's not a but it's a feature ;-)
Somewhere is the docs is written:
If you supply a connection (you _are_ doing this with openSession
(your_CONNECTION!)) _you_ have to be responsible for closing the
connection. Hibernate will only close connections that where created
directly by hibernate.
BTW:
- If you're using JBoss you can set the connection pooling to
"blocking" if there are no free connections left.
- If you're coding in a J2EE environment your beans should not access the
filesystem in a direct way (it is possible to load the mapping file via
class.getRessource (...))
HTH
Sven
--
Planung bedeutet den Zufall durch den Irrtum zu ersetzten.
_______________________________________________
Hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel