I am having problems inserting some rows that include ' -- i.e. an apostrophe. For instance M'PLX-W. My program inserts around 5 to 10 thousand rows a night. I can't manually put an escape character. Would anyone know how i can handle this. For this program i will be using MS SQL database. ps. I tried using prepared Statements -- and they seem to work fine; but much to my dismay prepared statements are (literally) running 20 times slower than the regular create statement.
I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
if its a form then when you get the data in the next page .. call a bean which modified the string by adding an escape character before the ' call the bean , set the string , call the modify function and then get the string by the getter method. use any string manipulation method like StringBuffer etc... i did the same .. then pass the modified string for insertion in the database... let me know if it works for you
sounds like you can do a few things to improve performance: 1. declare the PreparedStatement outside the loop to insert 10000 rows 2. Batch the preparedstatements example:
batching your statements will give you a huge performance gain. PreparedStatements when utilized properly will give you performance gains on repeated execution of the same statements. Give it a try and see what happens, or maybe post some relevant code (if there is a lot, then skeleton it for us!) Jamie
Joined: Jan 23, 2002
Thank you for the help -- everyone. I can't wait to try out your advice -- on Monday. I have a strong feeling it will work.
Joined: Jan 23, 2002
Hello Jamie. Wow!!! The batch update has made the program loop "faster than a speeding bullet". (although i used the regular create statement). I have one small problem though when using the batch update with a prepared statement -- the error reads: invalid transaction state java.lang.NegativeArraySizeException -- i think the line: int  inserts = ps.execut.. reads - (negative).