Jump to content
  • 0

Help With a Syntax Error


Question

Posted

Hello Guys.. Some One Can Help Me With This Error:

Here Is The Error In Console:

 

errorsql.jpg

 

And This Is The Java Code:

PreparedStatement statement = con.prepareStatement("" + "SELECT" + "characters.charId," + "characters.char_name" + "FROM" + "characters.account_name = accounts.login" +"WHERE" + "characters.onlinetime > 0" + "GROUP BY" + "accounts.lastIP" + "ORDER BY" + "characters.level" + "DESC");

 

Thx A Lot!

4 answers to this question

Recommended Posts

  • 0
Posted

use

PreparedStatement statement = con.prepareStatement("SELECT charId, char_name FROM characters WHERE account_name = ?");
statement.setString(1, "The_Account_name_goes_here");

 

Your error is caused because you dont let spaces anywhere, and the mysql engine cannot distinct between commands, columns and parameters

 

  • 0
Posted

Then.. This Is Right?:

 

PreparedStatement statement = con.prepareStatement("" + "SELECT" + " characters.charId," + " characters.char_name" + " FROM" + " characters.account_name = accounts.login" +" WHERE" + " characters.onlinetime > 0" + " GROUP BY" + " accounts.lastIP" + " ORDER BY" + " characters.level" + " DESC");

  • 0
Posted

i still dont understand why you use "string" + "string" + etc...

Also, you dont need to specify the table name before the column to call

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..