Forums Register Login

Why is this not working?

+Pie Number of slices to send: Send
Hello All,
I had this problem earlier and someone suggested to use the setAutoCommit() method. Well I did try it and I am still getting the same problem as below. Is there something wrong with how I have constucted my setAutoCommit method and the other methods that work with it?
PROBLEM:
I have an sql statment, inside a loop so each loop though it will insert the right data to the database. Lets say the code is going to loop 4 times. The problem is I have an error in my sql statement on the last loop, the 3 previous loops will execute but the last loop will thow an exception. This is not what I want, I want the code to thow the exception first before any data is executed to the database if there is an exception, if not then execute the data.

Thanks
Ben
+Pie Number of slices to send: Send
Until you execute the connection's commit() method, the changes you have made (i.e. the inserts) are not applied to the database. So, when you rollback(), it is as though you never executed the inserts. So, I'm not sure why their suggestion to use setAutoCommit(false)/commit()/rollback() is not working for you.
Is it an SQLException that occurs, or some other exception (e.g. IndexOutOfBounds, etc)?
+Pie Number of slices to send: Send
 

Originally posted by Blake Minghelli:
Until you execute the connection's commit() method, the changes you have made (i.e. the inserts) are not applied to the database. So, when you rollback(), it is as though you never executed the inserts. So, I'm not sure why their suggestion to use setAutoCommit(false)/commit()/rollback() is not working for you.
Is it an SQLException that occurs, or some other exception (e.g. IndexOutOfBounds, etc)?



Hello
The Exeception I get is this
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Postco'.
But I put a wrong name in there to test what would happen. The code that I am using loops though 4 times so on the first loop it gets the data it needs to retrieve and inserts that to the database the same with the other 2 loops. then it loops though the code again and then finds that there is a column name spelt wrong so it prints out an exception. Just a little more info, the code is inside the loop that loops 4 times if you want to see all of that code you can. But there is a lot and it is quite messy.
Hope this expains a bit more.
Thanks
Boggis
Heroic work plunger man. Please allow me to introduce you to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 712 times.
Similar Threads
commit() and rollback() problem!
maximum open cursors exceeded
How can you do this
Help with an error message
can this be solved
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:40:38.