I had existing function (f1) that opens and does select sql and returns results and closes connection.
Now I need to call the f1 many time. so in a loop
loop begins
f1
loop ends.
As long as the f1 opens and closes the jdbc connection I should not have any problem whatever the number of times it loops.
But I do see problem max connections sql exception
java.sql.SQLException: Network error IOException: No buffer space available (maximum connections reached?): connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(C onnectionJDBC2.java:385)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(C onnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.ja va:182)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.cleverdevices.bustime.util.DatabaseUtil.openDa tabaseConnection(DatabaseUtil.java:68)
at com.cleverdevices.bustime.scheduleevaluator.Schedu leEvaluator.getHistoricalScheduleAdherenceResults( ScheduleEvaluator.java:877)
at com.cleverdevices.bustime.scheduleevaluator.Schedu leEvaluatorIFImpl.getHistoricalScheduleAdherenceRe sults(ScheduleEvaluatorIFImpl.java:450)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages( Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocke tForJDBC3(SharedSocket.java:304)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(Shar edSocket.java:255)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(C onnectionJDBC2.java:310)
... 20 more
obviously if I connection before loop and close after loop it is ok. But my theory as long as we close everytime it should work ..
what is missing. "netstat" lists the db connections ports..
ofcourse when I stop the tomcat server..it clears.