jdbcTemplate和Oracle 10 [英] jdbcTemplate and Oracle 10

查看:66
本文介绍了jdbcTemplate和Oracle 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试插入,我有: jdbcTemplate.update(插入....",新的Object [] {foo.getId(),foo.getName()}) foo.getId()返回一个long,getName()返回一个String. 在Oracle中,我的ID类型为"NUMBER",名称字段为varchar2.

Trying to do an insert, I have: jdbcTemplate.update("insert into....", new Object[]{foo.getId(), foo.getName()}) foo.getId() returns a long, and getName() a String. I have "NUMBER" as the id type in Oracle, and varchar2 for the name field.

我遇到了SQLtype未知的问题. update方法的版本不需要输入SQL类型,但是我必须这样做,如果需要,怎么做?

I'm getting SQLtype unknown problem. the update method has a version where I do not have to put in the SQL types, but do I have to, and if so, how?

推荐答案

我假设您的意思是 Spring框架 JdbcTemplate 类. JdbcTemplate方法将尝试猜测 java.sql.Type 用于值引用,但显然在这种情况下无法正确猜测.

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:

JdbcTemplate.update(String, Object[]) [javadoc](

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.

或者,您可以使用JdbcTemplate.update(String, Object[], int[])传递 java.sql.Type

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

这篇关于jdbcTemplate和Oracle 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆