aspose file tools*
The moose likes JDBC and the fly likes Problem with JDBC + mysql delete query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with JDBC + mysql delete query" Watch "Problem with JDBC + mysql delete query" New topic
Author

Problem with JDBC + mysql delete query

Victor Naumenko
Greenhorn

Joined: Aug 22, 2012
Posts: 3
Good day.
Explain what is wrong:
Delete-query does not work in java-application, and a mysql-client - all works fine?
Here's the code:



A slightly different query:
Code:


-the same situation. In java NOT work ...

Help me? please!
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

Presuming you aren't getting any exceptions.
I can think of 2 options,

1) I have heard about debugging statements have you tried using one of those and seeing the actual string that is being used by the JDBC, then try running that yourself and see if it works.
2) you aren't comitting the work to the database, We can't see your connection, so you may have turned off autocomit, or not turned it on.


Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

And Welcome to the ranch.
Victor Naumenko
Greenhorn

Joined: Aug 22, 2012
Posts: 3
Wendy Gibbons wrote:Presuming you aren't getting any exceptions.
I can think of 2 options,

1) I have heard about debugging statements have you tried using one of those and seeing the actual string that is being used by the JDBC, then try running that yourself and see if it works.
2) you aren't comitting the work to the database, We can't see your connection, so you may have turned off autocomit, or not turned it on.



Thank's.

autocommit=true.

I tried this:


all the same does not work ...
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

Victor Naumenko wrote:
Wendy Gibbons wrote:Presuming you aren't getting any exceptions.
I can think of 2 options,

1) I have heard about debugging statements have you tried using one of those and seeing the actual string that is being used by the JDBC, then try running that yourself and see if it works.
2) you aren't comitting the work to the database, We can't see your connection, so you may have turned off autocomit, or not turned it on.



Thank's.

autocommit=true.

I tried this:


all the same does not work ...


In the example above you are setting autocommit=false, so turning it off oops.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

Wendy Gibbons wrote:In the example above you are setting autocommit=false, so turning it off oops.

But in the example above, commit is used too. It should work the same. I assume Victor was just trying it the other way just for sure.

I'm slightly suspicious of binding date values as Strings. Is the inputData.period column a VARCHAR or other text format? If it is actually declared as DATE, an implicit conversion takes place, which is prone to problems.
Victor Naumenko
Greenhorn

Joined: Aug 22, 2012
Posts: 3
Martin Vajsar wrote:
Wendy Gibbons wrote:In the example above you are setting autocommit=false, so turning it off oops.

But in the example above, commit is used too. It should work the same. I assume Victor was just trying it the other way just for sure.

I'm slightly suspicious of binding date values as Strings. Is the inputData.period column a VARCHAR or other text format? If it is actually declared as DATE, an implicit conversion takes place, which is prone to problems.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with JDBC + mysql delete query