0

I am using oracle database 10g express edition. Recently I am facing ORA-12516 error frequently. It says -- "java.sql.SQLException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack The Connection descriptor used by the client was: //127.0.0.1:1521/XE"

As far as I am concerned this error is shown when user doesn't close variables like "Statement" "Resultset" and opens a lot of them. Every time I created any "Statement" or "ResultSet" type variables in a function I used this function -- http://paste.ubuntu.com/7902053/ to close those variables. I didn't close those variables in a final block of the function inside which those were declared. Instead I called this function (close_calls(..)) to close those variables and sent them as parameters inside the function close_calls(..). For example I called the function given above in no 17 and 23 line here -- http://paste.ubuntu.com/7902114/

But this error is still shown in the console. Is close_call(...) not working ? How can I get rid of this error ? I got the idea of closing those variables from here --- Closing Database Connections in Java

Community
  • 1
  • 1
Pavel
  • 138
  • 2
  • 4
  • 16
  • There seems to be many open connections,so your DB is refusing additional connections. Quickest answer is to restart your DB ( If you have made proper closure of SQL Objects in your Java) – Maas Jul 30 '14 at 06:58
  • Please see my comment to HAL 9000 – Pavel Jul 30 '14 at 10:02

1 Answers1

0

Your code is leaking connections (not cursors or statements).

You've got to close the connections too, not only the statements and result sets - just as suggested by answer of that question you linked to.

HAL 9000
  • 3,877
  • 1
  • 23
  • 29
  • For the last code I was getting 4 ora-12516 errors.After changing I am still getting one ora-12516 error. Here I have shown a sample of many functions that use the database --- http://paste.ubuntu.com/7903343/ get_course_id_list() is the sample function. This is how I tried to close connections after working with each function -- http://paste.ubuntu.com/7903351/ close_call(..) is called from every function that has called establishConnection(..).Difference is in the previous code "Connection conn" was static and was not sent as parameter.Why 1 ora-12516 is still shown ? is my close_call() ok ? – Pavel Jul 30 '14 at 10:01
  • rethink your usage of try catch – HAL 9000 Jul 30 '14 at 10:24
  • I disagree. You can be in a situation where you need more connections. – MonoThreaded Jun 13 '16 at 20:51