jab*_*bal 6 java database spring clob
我通常使用lobHandler + JdbcTemplate + PreparedStatementSetter三元组将我的Clob插入到数据库中,正如我在http://www.java2s.com/Code/Java/Spring/InsertClobData.htm上看到的那样
我的问题是如何使用NamedParameterJdbcTemplate执行此操作?它没有接受神秘的PreparedStatementSetter接口作为参数的方法.
这可以在不使用PreparedStatementCallback和lobHandler的情况下工作,至少在插入字符串时是这样.
NamedParameterJdbcTemplate template; //= new NamedParameterJdbcTemplate(pDs);
String INSERT_STMT = "INSERT INTO MYTABLE (ID, LONG_TEXT) VALUES (:id, :clob)";
MapSqlParameterSource paramSource = new MapSqlParameterSource();
paramSource.addValue("id", 1L, Types.NUMERIC);
paramSource.addValue("clob", "a long long text", Types.CLOB);
template.update(INSERT_STMT, paramSource);
Run Code Online (Sandbox Code Playgroud)