how to tell the pool to allocate additional connections  
guest Wed Mar 26 14:28:35 GMT 2008
 
Hi:-) I have a problem with the pool- when the number of connections in the pool that are inactive (free to be used) gets to a very low level and in a moment becomes zero - the application throws exception because maybe there is a lag in the time the pool allocates new ones. So my question is how to tell the pool to allocate new connections when it reaches critical lack of free(inactive ready to process requests ) connections. I will be gratefull if you give me a clue:-) Thanx in advance and congratulations for the wonderful work on this project.

 
sedj Wed Mar 26 17:55:35 GMT 2008
 
Primrose uses "lazy" loading of connections. So if your app is not using connections, it kills them off. When a connection is required, it loads one for use, and then keeps it in the pool until its idleTime is once again met.
You should not need a "keep minimum number of connections" option.

What exceptions are you getting ?
guest Wed Mar 26 18:47:38 GMT 2008
 
thank you for your answer sedj, I face a very strange situation which is probably my fault. I get two very identical SQLExceptions first of which states that Statement is already closed and second that i cannot use next on ResultSet because it is closed and it asks me to verify that autocommit is off which is not in my case because i use autocommit on by default . Maybe it has something to do with the automatic closing that primrose does on unclosed resources as I observed from the log. I already know what you explained to me- i spent plenty of time examining the docs and sourcecode. I even managed to transform the monitor of connections into a servlet. I like primrose very much but this stupid exceptions drive me crazy - I spent whole day trying and reading every post in google I found about thee exceptions but there doesn't seem to have very much info. Any clue will be highly appreciated. maybe tomorrow I can post the exceptions when I have them. THank you very much for the time spent:-)
sedj Wed Mar 26 19:01:01 GMT 2008
 
Those two exceptions do sound user problems, rather than a bug in primrose. Are you sure you are not closing the statement objects twice, and are ot trying to read from a closed result set ?
guest Wed Mar 26 19:02:27 GMT 2008
 
I don't blame you for anything dude, probably you are right and it is due to some misplanning of the architecture of the application that i work on. It is very strange though - i use preparedstatements and i close them and their corresponding resultsets immediately after I use them. Maybe in some parts of my application i might have forgotten to close some of them but primrose writes in the logs that it closes them. What is bad i gues is that after it reports this it prints a stack trace of some exception that i can't quite understand. Do you think it is possible that this forceable closing messes my work. Or maybe my problems are due to the fact that I use one connection form many queries (not getting seperate connection for every query of the database). What I am sure about is that in the end I call close() method of the connection. Sorry for the dull discussion but I am new to connection pooling. I have been using proxool api for connection pooling before I discovered primrose. To be honest i like primrose more because it is better coded(more understanding) and frequently supported. I like the architecture more and what is more i got exceptions with proxool similar that I get with primrose and that seems is my fault:-( But the exception that the statement is closed is new and I get it after started using primrose.... maybe having something to do with the automatic closing of the unclosed resources. Our application is very large and gets a very heavy load. What is worst we are only three developers working on it on a very tight schedules which results in messy coding. Maybe tomorrow i can post these exceptions... if I haven't already got on your nerves;-) Thank you for the support!!
sedj Wed Mar 26 20:25:58 GMT 2008
 
You say that you use one connection for many statements - this way of using JDBC is fraught with danger I'm afraid.

If you are not using connection pooling, then I could see why you might want to do that, but if using connection pooling, your style really should be :

Get Connection
Execute Statement
Read result set (if appropriate)
close result set (if appropriate)
close statement
close connection.

All "closes" should be done in a finally block :

try {

do stuff

} catch (Exception)
handle exception
} finally {
close stuff
}

If you don't follow that style, you will get yourself in a mess.

You say you got similar problems when using proxocol - that says to me its more a coding issue your side rather than the pool (sorry!).

guest Wed Mar 26 20:44:58 GMT 2008
 
yes yes yes, you are absolutely right - I spent the last few hours reading about those kind of issues in the forums and your posting makes sense now - I should adopt the practice to get connections form the pool for every query i execute and then close them and their resources (if I got you right). This seems fair to me. And yes - when I joined the team that was developing the application the connection pooling was never taken in consideration. And one shiny day the boss wanted it... so here I am. Thank you very much for clarifying these things to me - those knowledge saved me sleepless hours in front of the pc.Thank you :-))))
guest Thu Mar 27 09:47:52 GMT 2008
 
Hi again, I tried to rewrite part of the code taking in consideration the advices you gave me but something strange happens. I opne a connection for every query that i make and immediately i close it as it should be. However primrose monitor shows that even though connection are closed they are still active and reallocates more on the next request which results in many connections alocated exponentially. Do you have an idea what the cause of that can be ;-)????
sedj Thu Mar 27 18:45:54 GMT 2008
 
Sounds like you are not closing the connection object .. are you sure you are doing it like this :



Connection c = null;
Statement s = null;
ResultSet rs = null;

try {
c = getMyConnection(); // look up the datasource, and get a connection
s = c.createStatement();
rs = s.executeQuery("select * from bla");
while (rs.next()) {

// do stuff
} catch (SQLException sqle) {
// sqle.printStackTrace();
} finally {
// Cose the result set
if (rs != null) try { rs.close(); } catch (SQLException sqle2) { sqle2.printStackTrace(); }
// Close the Statement obj
if (s != null) try { s.close(); } catch (SQLException sqle2) { sqle2.printStackTrace(); }
// Close the Connection obj
if (c != null) try { c.close(); } catch (SQLException sqle2) { sqle2.printStackTrace(); }
}