试图从Java访问AS400/DB2存储过程Spring的JdbcTemplate

问题描述:

试图从Java访问AS400/DB2存储过程Spring的JdbcTemplate,试图从Java访问AS400/DB2存储过程Spring的JdbcTemplate

XmlBeanFactory beanFactory2 = new XmlBeanFactory(new ClassPathResource(
       "datasource_as400.xml")); 
     DataSource ds2 = (DataSource) beanFactory2.getBean("dataSource"); 

     jdbc2 = new JdbcTemplate(ds2); 

     jdbc2.update("{CALL TESTONE(?)}", new Object[] { new String("JOHN") }); 

,我收到以下错误

[DEBUG,SQLErrorCodeSQLExceptionTranslator] Translating SQLException with SQL state '42704', error code '-204', message [[SQL0204] TESTONE in type *N not found.]; SQL was [{CALL TESTONE(?)}] for task [PreparedStatementCallback] 
[FATAL,MainBatch] processDonations(): org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [{CALL TESTONE(?)}]; nested exception is java.sql.SQLException: [SQL0204] TESTONE in type *N not found. 

根据iSeries Info Center,SQLCODE -204表示An undefined object or constraint name was detected.

您可能必须指定模式功能在(I.E.,CALL YOUR_SCHEMA.TESTONE(?))。

如果它在另一个程序中工作(或手动查询时),您的架构路径可能会设置不同。你可以通过做SELECT CURRENT_SCHEMA FROM SYSIBM.SYSDUMMY1来检查(我不知道SYSIBM.SYSDUMMY1是否在iSeries上,或者是否有另一个虚拟表的名字......我习惯z/OS或Linux/Unix/Windows DB2)。

+0

我试图添加架构,但它没有帮助 – SJS 2012-03-14 19:08:44

+0

另一个想法可能是您的过程期望某种数据类型进来,而Spring将它作为另一种类型发送?在这种情况下,您可以将“CAST(?AS型)”添加到您的参数中。有时DB2可能会对过程中的数据类型挑剔。 – bhamby 2012-03-14 20:51:21

+0

谢谢galador我们也试过,:( – SJS 2012-03-15 13:59:02