WebFaction
Community site: login faq

Hi:

I'm just trying a Java console application to talk to my MySQL. It appears that I can connect to my MySQL instance fine but I get error messages when I invoke a simple select command. Here is the error message.

Your SQL : select * from show Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'show' at line 1

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2569)
    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1510)
    at com.bdeshtv.java.DbTest.webbfactionDb(DbTest.java:107)
    at com.bdeshtv.java.DbTest.main(DbTest.java:62)

And here is my Java class (part of code) that I"m using..

*public static void main(String[] args) throws Exception {
    DbTest dbTest = new DbTest();
    String sql = "select * from show";
    dbTest.webbfactionDb(sql);
}
public String webbfactionDb(String sql) throws Exception {
    try {
        Class.forName("com.mysql.jdbc.Driver");
        connect = DriverManager.getConnection("jdbc:mysql://web159.webfaction.com:3306/mydatabase","myuserid","mypassword");
        statement = connect.createStatement();
        resultSet = statement.executeQuery(sql);
        writeResultSet(resultSet);
        String resultStr = readAsString(resultSet);
        return resultStr;
    } catch (Exception e) {
        throw e;
    } finally {
        close();
    }

}*

Has anyone ran into this issue before? Thanks.

_Iqbal

asked 19 Jun '11, 23:05

iyusuf
1124
accept rate: 0%

Can you try with "show tables" instead of the select query and use localhost for connection to the database?

(19 Jun '11, 23:15) neeravk
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×168
×22
×2

question asked: 19 Jun '11, 23:05

question was seen: 2,755 times

last updated: 19 Jun '11, 23:15

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM