I have a table called Produkt and in this table there are several products called test.
When I want to do that code:
public Produkt findByName(String name) throws SQLException{
log.error("Enter findByName with parameters: " + name);
PreparedStatement ps;
ResultSet rs = null;
String query = "SELECT * FROM Produkt WHERE name=" + name;
ps=hsqlmanager.getConnection().prepareStatement(query);
rs = ps.executeQuery();
ps.close();
if(rs.next()) return(new Produkt(rs));
else return(null);
}
it always gives me an sql error:
Exception in thread "main" java.sql.SQLSyntaxErrorException: user
lacks privilege or object not found: TEST at
org.hsqldb.jdbc.Util.sqlException(Unknown Source) at
org.hsqldb.jdbc.Util.sqlException(Unknown Source) at
org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source) at
org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source) at
dao.DAOProdukt.findByName(DAOProdukt.java:157) at
dao.test_produkt_dao.main(test_produkt_dao.java:23)
why? i appreaciate your answer!!!
UPDATE:
Why are the PS incorrectly used? Pls tell me so that I can learn from that?