I would need to update an existing row in a table in MySQL database, or create it if it is not existing.
I am using com.mysql.jdbc.Driver.
What is Spring way to do that, with preferably with PreparedStatement?
I am trying to do something like this, bar1 is the key:
Code:String SQL_CMND= "INSERT INTO foo(bar1, bar2, bar3) values (?, ?, ?)" + "VALUES (1, 2, 3)" + "ON DUPLICATE KEY UPDATE bar1= ?, bar2=?, bar3=?"; jdbcTemplate.update(SQL_CMND, new PreparedStatementSetter() { public void setValues(PreparedStatement ps) throws SQLException { ps.setInt(1, 1); ps.setInt(2, 2); ps.setInt(3, 2); }});


Reply With Quote