MySQL/JDBC Prepared Statement Select query
I am having trouble with a select query using a prepared Statement.
I have as follows:-
String query = "select statement.dateOut, statement.amountOut from statement, account where "
+ " account.account_number = statement.account_number and account.account_number = ?";
PreparedStatement ps = connection.prepareStatement(query);
ResultSet rs = ps.executeQuery(query);
dateWithdrawn = rs.getDate("dateOut");
checkStatement = rs.getInt("amountOut");
System.out.println("\n Balance " + accountBalance +
"\nAmount Out " + checkStatement +
"\tdate" + dateWithdrawn);
I keep getting the message:-
com.mysql.jdbc.exceptions.MySQLSyntaxErrorExceptio n: 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 '?' at line 1
Any help appreciated