尝试插入,我有: jdbcTemplate.update(<!> quot; insert into .... <!> quot;,new Object [] {foo.getId(),foo.getName()}) foo.getId()返回一个long,getName()返回一个String。 我有<!>“NUMBER <!>”;作为Oracle中的id类型,以及名称字段的varchar2。

我收到SQLtype未知问题。 update方法有一个版本,我不需要输入SQL类型,但是我必须这样做,如果是,如何?

有帮助吗?

解决方案

I'm assuming you mean the Spring Framework JdbcTemplate class. The JdbcTemplate methods will attempt to guess the java.sql.Type for value references, but apparently isn't guessing correctly in this case.

There are a couple of ways to include the type:

The JdbcTemplate.update(String, Object[]) [javadoc](http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/JdbcTemplate.html#update(java.lang.String, java.lang.Object[])) indicates that you can pass SqlParameterValue instances, consisting of the java.sql.Type and a value.

Alternatively, you can use JdbcTemplate.update(String, Object[], int[]) passing an array of java.sql.Type

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top