Results 1 to 4 of 4
  1. #1
    devadam4 is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Desktop application querying problem from panel

    I have a simple desktop application and also i have class name baseClass. When i run the program, a frame is occured and i set an event handler for a button. When this button clicked i call a function from baseClass and send a table name as a parameter to this function. And this function executes a sql statement. I have a problem with this sql query. It throws exception like "You have an error with SQL syntax etc..." But i think there is not.

    statement.executeQuery("SELECT * FROM '"+tableName+"'");
    statement.executeQuery("SELECT * FROM gamesonstore");

    My table name is gamesonstore. First line throws exception but second line works. I checked if problem is occured because of overridable method call from constructor or not. But in this case i supposed second line throws exception also but it doesnt. So what is the problem with this ? My exception is:

    "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''gamesonstore'' at line 1"

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Desktop application querying problem from panel

    "You have an error with SQL syntax etc..." But i think there is not.
    When there is a difference of opinion like this the database and Java runtime win.

    Perhaps you could take a look at the expression that is invalid:

    Java Code:
    System.out.println("About to execute: " + "SELECT * FROM '"+tableName+"'");
    statement.executeQuery("SELECT * FROM '"+tableName+"'");
    What happens when you type that command directly into a database client?

  3. #3
    devadam4 is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: Desktop application querying problem from panel

    I used similar almost same expression but there is not exception. They are working.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Desktop application querying problem from panel

    I don't understand.

    Did you add the line I suggested? What output did it produce? What does that output yield when you enter the command directly into the mysql client? How did the output from that line differ from that which you used in the other executeQuery() (the one that did not throw the exception)?

    [Edit] Or have a read of http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
    Last edited by pbrockway2; 12-22-2011 at 11:47 PM.

Similar Threads

  1. setup related problem on Java Desktop Application
    By ravi.iise08@gmail.com in forum Advanced Java
    Replies: 1
    Last Post: 10-25-2011, 06:03 PM
  2. Desktop Application
    By vineet osho in forum New To Java
    Replies: 3
    Last Post: 06-13-2010, 05:37 AM
  3. Replies: 3
    Last Post: 12-04-2009, 12:10 PM
  4. Problem running a java desktop application
    By chris@gaiag.net in forum AWT / Swing
    Replies: 2
    Last Post: 08-24-2008, 04:24 AM
  5. querying russian data from db problem
    By mr_empty in forum JDBC
    Replies: 0
    Last Post: 03-04-2008, 07:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •