It's must work/ for example
Select from Employee e where e.ID < ? and e.ID >= ? order by e.ID
to set values use this:
int id1 = 1; int id2 = 10; preparedStatement.setInt(2, id1); preparedStatement.setInt(1, id2);
for delete I use this code:
public synchronized boolean deleteNewsById(Integer[] idList) throws NewsManagerException { DatabaseConnection connection = pool.getConnection(); StringBuffer buffer = new StringBuffer(); buffer.append("("); buffer.append(idList[0]); for (int i = 1; i < idList.length; i++) { buffer.append(","); buffer.append(idList[i]); } buffer.append(")"); PreparedStatement statement = connection .getPreparedStatement(DELETE_NEWS_BY_ID + buffer); }
and sql query looks like this
private static final String DELETE_NEWS_BY_ID = "delete from NEWS where ID in ";
or simple write delete from NEWS where ID in (?,?,?) and set values like in first example