java - Perform Update using Spring jdbctemplate -
Please use a jdbctemplate to give a suggestion of doing the query below.
Update student set result = 'pass' where stud_id (100,101,102);
I tried the following, but stuck with an invalid column type.
I
string query = "I'm passing the update student exam result = WHERE in OBJ_ID (select from the table)"; Int [] stud_ids = new int [] {100,101,102}; GetJdbcTemplate (). Query (UpdateState SQL, New PreparedStatetsetter) {@ Override Public Void Set Valves throws SQL Connection (Last Connection = = MilliDBC Template) GetNativeJdbcExtractor (). GetNativeConnection (ps.getConnection ()); Ps.setstring1, 'pass'); Ps.setArray (2, stud_ids);}}, new romp at & lt; String & gt; () {@ Override public string map mark (as a result, Rs, int arg1) throws SQLException {return rs.getString (1); }}); }
You have written:
string queries = "Set student exam =? Where in OBJ_ID (select from table)"; GetJdbcTemplate (). Query (updateStateSQL, ...)
You have not written the value of updateStateSQL
if it is like query
, then this does not work Can:
ps.setString (1, 'PASS'); Ps.setArray (2, stud_ids);
Because you will need exactly 2 question marks (?
) in the query and you only have one in your post.
You can try it:
string query = "set student exam =? Where in OBJ_ID (?)";
But honestly, I have never used ps.setArray
and I'm not sure that it will fulfill your expectations.
should work
string sql = "update student set result =: result WHERE OBJ_ID IN : IDes) "; Maps & lt; String, Object & gt; Parameters = new Hashmop & lt; String, Object & gt; (); Params.put ("Results", "PASS"); Params.put ("id", arrays.asList (new integer [] {100, 101, 102})); GetSimpleJdbc Template () Update (SQL, Parameters);
Comments
Post a Comment