File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Bind Variable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Bind Variable?" Watch "Bind Variable?" New topic

Bind Variable?

Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
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.


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

[edited by Jeanne to add code tags]
[ May 23, 2005: Message edited by: Jeanne Boyarsky ]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

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.)

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Use a profiler. See the following Web site for more information on profiling java applications:

Good Luck,
I agree. Here's the link:
subject: Bind Variable?
It's not a secret anymore!