• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Error connect to db after several transaction

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I've encountered error connecting to db while inserting records into postgresql using java.

i have 4k records to be inserted to db from a text file,
first i read the text file and put into List<String>
and from List, i do a for loop for each string in the list to insert to db.
the program run without any problem until around 1960+ records, it throws :-
org.postgresql.util.PSQLException: The connection attempt failed.

i did close rs,ps,con for each newly created connection.

is it a postgres problem or java problem?

Thanks
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Koon Jiun:


is it a postgres problem or java problem?



I can say that there must be something is incorrect in your code not in postgres/java. Exception is occur d when something is incorrect or may be in your db connection code..

could your share you code or stack trace to help you to find out this problem.
 
Koon Jiun
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Exception in thread "main" java.lang.RuntimeException: org.postgresql.util.PSQLException: The connection attempt failed.

it throws this error after 1960+- records inserted

what could be the problem?
[ December 18, 2006: Message edited by: Koon Jiun ]
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Koon Jiun:



Do some changes to paste Line 1 and 2 after the for Loop bracket "}". Actually in your For Loop connection and prepared statement object were created and close on every record insertion. like what you said its insert 1960+ record in the database hope you will understand. please do separate this code to reduce the time of extra process and increase the performance.

hope it helps..
[ December 19, 2006: Message edited by: Saif uddin ]
 
Don't MAKE me come back there with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic