| Author |
insert query not executing..
|
timothy smith
Greenhorn
Joined: Jun 07, 2007
Posts: 11
|
|
hello! in my project i use an insert query .. i dont get any exceptions and the project runs normally but when i check my database the new data hasnt been added! what could go wrong? here is my code: any ideas??
|
 |
Herman Schelti
Ranch Hand
Joined: Jul 17, 2006
Posts: 387
|
|
hi Timothy, some hints: -log your sql-exceptions in the catch block, seewhat you will get. catch (SQLException ex) { //log here } -do the closing in a finally block (not in the catch block) finally{ .. I CLOSE CONNECTION ,PREPAREDsTATEMENT } Herman PS please post real code if possible instead of re-typing it.
|
 |
timothy smith
Greenhorn
Joined: Jun 07, 2007
Posts: 11
|
|
hello! i just thought to write the code which had to do with the problem.. i use finally block and catch all sql exception.. eventually my problem turned out to be not the query but something else..(?) i have made a little test and tried to execute the query "insert into my_table (USER_ID, MOVIE_CAT1)values (?, 1)" but no new data was added in the table, when still i get no message for exception . i have several other functions for writing in the databasewhich work fine!i created the table using mySqlAdministrator and when i make the query in mySqlQueryAnalyzer it works perfectly! what could cause this problem?
|
 |
timothy smith
Greenhorn
Joined: Jun 07, 2007
Posts: 11
|
|
hello again! it turned out that the problem had to do with an option in mySqlAdministrator! i had used navicat to create the other tables. as for the table i wanted to add information, it was created using MySQLAdministrator. Another engine instead of ISAM which was the option for all the other tables in database was set by default! when i changed that it worked! if anyone knows why this happened it would be interesting to know!
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26144
|
|
Timothy, Thanks for posting the solution so that others who see this thread in the future can benefit!
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: insert query not executing..
|
|
|