5 Replies - 642 Views - Last Post: 07 April 2009 - 07:47 PM Rate Topic: -----

#1 chrisd234  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 10-June 08

JavaDB sql works one day, doesnt the next

Posted 06 April 2009 - 05:51 PM

Hello everyone,
I was inspired by gmail's april fools day joke and decided to write an email auto-reply program that checks emails then replies to them.

I'm at 75% complete, including most databases working fine, checking email, just have to write the sending.

Last night this JavaDB command worked 100% fine:

LOCK TABLE OUTBOX IN EXCLUSIVE MODE; DELETE FROM MAIL WHERE ID ="+rowNumber;


It worked great. rowNumber is an integer, and it would delete the appropriate record. I used it several times.

Today, I'm working on coding some other portions of the program and polishing it. None of these have anything to do with the class that handles this. I try to walk through the program again, and I'm getting this:

Syntax error: Encountered ";" at line 1, column 36.

from the stack trace.

So I put a JOptionPane.showMessageDialog() with the sql statement in it, to check if there was more than one ; in the statement. Nope, statement works fine. It works if I copy and paste it to the sql command prompt.

It doesnt work, when the program tries to execute it though. am I missing something? If I remove the ; it throws an error for not having it there.

Is This A Good Question/Topic? 0
  • +

Replies To: JavaDB sql works one day, doesnt the next

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: JavaDB sql works one day, doesnt the next

Posted 06 April 2009 - 06:38 PM

View Postchrisd234, on 6 Apr, 2009 - 04:51 PM, said:

LOCK TABLE OUTBOX IN EXCLUSIVE MODE; DELETE FROM MAIL WHERE ID ="+rowNumber;

You are in the Java forum... this is not Java code but I can tell you that you have a single "
surely not a good idea in any language
Was This Post Helpful? 0
  • +
  • -

#3 chrisd234  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 10-June 08

Re: JavaDB sql works one day, doesnt the next

Posted 06 April 2009 - 06:41 PM

View Postpbl, on 6 Apr, 2009 - 05:38 PM, said:

View Postchrisd234, on 6 Apr, 2009 - 04:51 PM, said:

LOCK TABLE OUTBOX IN EXCLUSIVE MODE; DELETE FROM MAIL WHERE ID ="+rowNumber;

You are in the Java forum... this is not Java code but I can tell you that you have a single "
surely not a good idea in any language



I posted in the java forum because I'm sending this SQL command to a the server via Java, and the sql command work fine if I enter it manualy, but when my java program passes it, it give an error saying it encountered ";".

I left off the " from the beginning of the string by accident. its's string+rowNumber
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: JavaDB sql works one day, doesnt the next

Posted 06 April 2009 - 06:47 PM

View Postchrisd234, on 6 Apr, 2009 - 05:41 PM, said:

View Postpbl, on 6 Apr, 2009 - 05:38 PM, said:

View Postchrisd234, on 6 Apr, 2009 - 04:51 PM, said:

LOCK TABLE OUTBOX IN EXCLUSIVE MODE; DELETE FROM MAIL WHERE ID ="+rowNumber;

You are in the Java forum... this is not Java code but I can tell you that you have a single "
surely not a good idea in any language



I posted in the java forum because I'm sending this SQL command to a the server via Java, and the sql command work fine if I enter it manualy, but when my java program passes it, it give an error saying it encountered ";".

I left off the " from the beginning of the string by accident. its's string+rowNumber

Depends on how leniant your SQL engine is.
Your SQL statement is not valid it does not end with a ;
Was This Post Helpful? 0
  • +
  • -

#5 chrisd234  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 10-June 08

Re: JavaDB sql works one day, doesnt the next

Posted 07 April 2009 - 07:45 AM

Quick follow up and question....

I did some more reading today, and it seems that while I was closing all resultSets and Connections, I wasnt closing all statements.

My program is setup to connect and disconnect from the database as needed, and sometimes there are alot of queries going one after another, in seperate statements. If these statements are left unclosed, could this cause a deadlock?
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: JavaDB sql works one day, doesnt the next

Posted 07 April 2009 - 07:47 PM

View Postchrisd234, on 7 Apr, 2009 - 06:45 AM, said:

Quick follow up and question....

I did some more reading today, and it seems that while I was closing all resultSets and Connections, I wasnt closing all statements.

My program is setup to connect and disconnect from the database as needed, and sometimes there are alot of queries going one after another, in seperate statements. If these statements are left unclosed, could this cause a deadlock?

Not at all don't worry about that
OK it is nicer to be clean and to show that you know what are doing but not mandatory
Java will handle correctly a ResultSet lost in the limbs
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1