• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bind Variable?

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need help in making the JDBC call in my code more efficient.

I have written XML parser to parse XML file to create appropriate Insert statment from the file.

In method endElement in testcalss I am making call to class InsertData.

Please see below for the code of InsertData.

Can someone help me to make this code efficient. I need to run each insert statement seperately so that even if one of the Insert fails the program continues.
Is use of PrepareStatment OK or do I need to change this? If and how can I use Bind Variables here?

The program runs fine for smaller files but when the file size is huge (9MB ) the program is too slow or fails with memory issues.







Thanks!
Gemini

[ May 23, 2005: Message edited by: Gemini Moses ]

[edited by Jeanne to add code tags]
[ May 23, 2005: Message edited by: Jeanne Boyarsky ]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gemini,
You should definitely use a PreparedStatement. Sun's tutorial on this is excellent.

Try inserting some println statements in the code to see what part is taking the most time. Is it the JDBC, XML, etc. (Either way you should use a PreparedStatement though.)
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gemini,
Use a profiler. See the following Web site for more information on profiling java applications:

http://www.javaperformancetuning.com

Good Luck,
Avi.
 
reply
    Bookmark Topic Watch Topic
  • New Topic