Using prepared statements with JDBCTemplate

前端 未结 5 894
既然无缘
既然无缘 2021-01-31 16:16

I\'m using the JDBC template and want to read from a database using prepared statements. I iterate over many lines in a .csv file, and on every line I execute some SQL select qu

5条回答
  •  感情败类
    2021-01-31 17:07

    Try the following:

    PreparedStatementCreator creator = new PreparedStatementCreator() {
        @Override
        public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
            PreparedStatement updateSales = con.prepareStatement(
            "UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ? ");
            updateSales.setInt(1, 75); 
            updateSales.setString(2, "Colombian"); 
            return updateSales;
        }
    };
    

提交回复
热议问题