• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting Socket Exception ,No buffer space ,maximum connection reached  RSS feed

 
pooja rathi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Here I am trying to connect java program with database but when i am trying to insert large data say for 1 month so its only fetching 16000 records not more than that i want the data should be inserted as per the given date range what should i do to get that . In stacktrace its showing an exception as no buffer space available maximum connection reached. Thanks In advance
 
Les Morgan
Rancher
Posts: 779
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I follow the flow of your code correctly, you get a connection and new statement every time through your for loop, this is not the way to do it.

Get your connection outside the loop, and build a parameterized query for your insert.

Then update you parameters in the loop and then execute. That way you don't get 16,000 distinct connections and statements and causing your program to run out of resources.

1 connection and 1 parameterized query is all you need.
 
pooja rathi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you explore more a little bit by giving an example
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!