-->
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.  [ 2 posts ] 
Author Message
 Post subject: java.sql.SQLException: Data source rejected establishment of
PostPosted: Fri Mar 16, 2007 2:09 am 
Newbie

Joined: Wed Dec 06, 2006 2:40 am
Posts: 2
Location: HYDERABAD
Hi,

iam vijay, iam using Hibernate for my project when iam connecting to the MySQL database, iam getting the following error

java.sql.SQLException: Data source rejected establishment of connection, message from server: "Too many connections"

iam looking forward for your reply


Thanks in advance
vijay



Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

_________________
M.VIJAY


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 2:24 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi vijay.maddala

I think there is connection leak in your code .Try to find it and while running your application monitor connection pool in MySQl.If all connection are utilized then increase pool size. pool size should be in limit of 250.which is average. Also you could set pool size in cfg file.

Try Use c3p pool connection .It has very good pooling mechanism.
have a look

http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html



Hibernate is leaking JDBC connections!
There are three possible reasons why Hibernate might not be closing connections

You are forgetting to call Session.close().
This is the most common cause. Consider carefully how you are handling sessions. Are you sure you create only one Session per transaction? Are you certain you close the Session even if an exception occurs (ie. in a finally block).

Hibernate issues a warning in the log when an unclosed session is garbage collected, so looking there is a good place to start.

Hibernate is doing connection pooling.
Which ConnnectionProvider are you using? If its not DatasourceConnectionProvider, then it is probably doing connection pooling. This can cause problems in certain environments. Pooling may be disabled for DriverManagerConnectionProvider by setting hibernate.connection.pool_size=0 in hibernate.properties.

You are supplying your own connection.
If you supply your own JDBC connection to SessionFactory.openSession(), Hibernate does not close it from Session.close().

In any case, you can always bypass Hibernate's Connection and transaction handling altogether. For example, the following code block shows the application managing connections and transactions manually:

Session s = sf.openSession( getMyJDBCConnection() ); //supply a JDBC connection
try {
// do some work
s.connection().commit();
}
catch (Exception e) {
s.connection().rollback();
}
finally {
s.close().close(); //close the session and user-supplied JDBC connection
}

_________________
Dharmendra Pandey


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