• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Eclipse , syntax error on token(s)

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I have this code, but I got these errors in lines 12, 13 and 14

error in line 12 says :
syntax error on token(s) misplaced construct(s)
syntax error on token(s)"Invalid Character" , delete this token
syntax error , insert ";" to complete LocatVariableDecrationStatement

error in line 13 says :
syntax error on tokens, delete this token

error in line 14 says :
syntax error on tokens, Expression expected instead
syntax error on tokens, delete this token

1 public boolean validateUser(String username, String password)
2 {
3 boolean valid = false;
4
5 Connection con = null;
6 Statement stmt = null;
7 ResultSet rs = null;
8 try
9 {
10 con = dataSource.getConnection();
11 stmt = con.createStatement();
12 rs = stmt.executeQuery(�SELECT * FROM Users � +
13 �WHERE username = �� + username + 14 �� � + �AND password = �� + password + ���);
15 16 if (rs.next())


Could you please help me.
Thank you.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, if the above is an exact replica of your code, you're using nonstandard characters instead of the kind of quote marks that Java expects. You're using '�' characters, when a standard double quote is a '"' character, and you've got "�" characters instead of "'" characters, which will most likely upset the JDBC driver when you send this query to a database.

I can't tell if those are Microsoft curly quotes (did you cut-and-paste this to/from Word?) or if it's a localization issue, but in any case, those quote are not valid in Java source code.
 
majid nakit
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much, it works now.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic