SpringJDBC调用函数及存储

springJDBC中当sql中用到char时,最好转为String传入.
而不要传入character,否则会报:uncategorized SQLException for SQL[]error code [17004]; 无效的列类型.

究其根源,是用到了jdbc中的PreparedStatement,而PreparedStatement当用于oracle中时,就有这点char型不识别.
getJdbcTemplate().queryForList(sb.toString(), params);
如果用的是oracle数据库,params中不要加入char型.

还有一点:SpringJDBC当用到函数时,
setFunction(true);
用过存储过程时,
setFunction(false);
//一看下面就应该知道,SFUNC_NAME一定是一个存储过程
public AddCustomerInfoPro(DataSource ds) {
			super(ds, SFUNC_NAME);
			setFunction(false);
			declareParameter(new SqlParameter("p_customerNo", Types.VARCHAR));
			compile();
		}

猜你喜欢

转载自love398146779.iteye.com/blog/1565336