File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

insert query not executing..

 
timothy smith
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 387
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 33700
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Timothy,
Thanks for posting the solution so that others who see this thread in the future can benefit!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic