Trying to access AS400/DB2 stored procedure from Java with 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") });
and I am getting the following Error
[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.
According to the iSeries Info Center, SQLCODE
-204meansAn undefined object or constraint name was detected.You may have to designate the schema your function is in. (I.E.,
CALL YOUR_SCHEMA.TESTONE(?)).If it works in another program (or when you query manually), your schema path may be set differently. You can check by doing
SELECT CURRENT_SCHEMA FROM SYSIBM.SYSDUMMY1(I’m not sure ifSYSIBM.SYSDUMMY1is on iSeries, or if there is another name for the dummy table… I’m used to z/OS or Linux/Unix/Windows DB2).