CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Jul 2009
    Posts
    105

    MySql Error in Java program

    Hello,

    I'm not really sure if this is the right area i should be putting this(so i'm going to post it both in java section and this section) but here is the problem.

    I am getting the following error

    Code:
    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 '> 2010-01-15 ORDER BY date ASC LIMIT 1' at line 1
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    	at java.lang.reflect.Constructor.newInstance(Unknown Source)
    	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:2625)
    	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
    	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2281)
    	at Main.Database.execute(Database.java:153)
    	at Analysis.Analysis_A.main(Analysis_A.java:40)
    The problem is, my code seems right because when i plug it into the actual SQL query box in MySql it runs perfectly fine.

    Here is the code that is erroring up:

    Code:
    Date date = (Date) RS.getObject(1);
    					double percentChange = RS.getDouble("percentChange");
    					ResultSet RS2 = newConnection.execute("SELECT date, percentChange FROM " + tickerMaster[x] + "WHERE date > " + date + " ORDER BY date ASC LIMIT 1");
    I am obtaining the box contents using an object, however i am parsing it as an SQL Date. I have also tried using getDate(1).

    If you could help, it would be greatly appreciated

    -Alex
    Last edited by Alexz003; January 16th, 2012 at 09:18 AM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured