• Post Reply Bookmark Topic Watch Topic
  • New Topic

No error in connection but in writing Data

 
Huzefa Zohaib
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using hsqlbd database. The tutorial is available on http://www.mycgiserver.com/~buman.
But the basic problem is that, there is no error or exception in opening or closing the connection.
But "line 1" is giving "false", and, when I use line 2 instead of line 1 it
gives "1" but not entering any data.
Please help me to this problem.
 
Bharat Ramchandani
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for any DML i believe we need to use executeUpdate(String stmt)
try using stat.executeUpdate(SQL)
HTH
brat
 
Andy Bowes
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use either statement.execute() or statement.executeUpdate() to perform the SQL statement in the database.
The return value of false just after executing the SQL statement just indicates that there were no ResultSets generated. This is what you would expect.
It looks as though BOTH the execute() and executeUpdate() methods are working as intended. You might try ensuring that the changes are committed to the database by executing a commit() on the Connection after performing the INSERT.
You could also check if autoCommit is turned on on the connection.
HTH
Andy Bowes

p.s.
The code should also be tidied up a bit so that the release of the statement & the connection is performed in a finally block.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!