Using SQL's "IN" in JDBC
In SQL, the IN operator is used to restrict columns to one of a set of values. Using IN in JDBC, though, is sometimes problematic because of the way different databases handle prepared statements. With JDBC, prepared statements use ? to serve as markers for values in a SQL statement. Thus, you might see: PreparedStatement ps=connection.prepareStatement("SELECT * FROM FOO WHERE BAR = ?"); This serves to help prevent SQL injection attacks; assigning a value of "'' or...
Jan 18, 2016 — 4 minute(s) read