Problem Spring JdbcDaoSupport, StoredProcedure
Bonjour,
Je suis entraine d'essayer d'invoquer une procédure stokée via une classe qui implémente JdbcDaoSupport de Spring, J'obtient l'erreur suivante :
Citation:
GRAVE: SQL Exception occurred at runStoreProc.
org.springframework.jdbc.UncategorizedSQLException : CallableStatementCallback;
uncategorized SQLException for SQL [{? = call avisante.santeclair.identification()}];
SQL state [72000]; error code [1008]; ORA-01008: not all variables bound
; nested exception is java.sql.SQLException: ORA-01008: not all variables bound
Voici ma classe Dao
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| /**
*
*/
package avilog.spring.jdbc.test;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlAp plicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.support.JdbcDaoSuppo rt;
import org.springframework.jdbc.object.StoredProcedure;
/**
* @author
*
*/
public class TestDaoImpl extends JdbcDaoSupport {
private static final String spName = "avisante.santeclair.identification";
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-context.xml");
TestDaoImpl daoImpl = (TestDaoImpl)ctx.getBean("testDaoImpl");
String nom = null; String prenom = null;
int numAdr = 123456;
daoImpl.runStoreProc(spName,numAdr,nom,prenom);
}
public int runStoreProc(String spName, int numAdr, String nom, String prenom) {
int status = -1;
try {
MyStoreProcedure sp = new MyStoreProcedure (getJdbcTemplate().getDataSource(), spName);
Map results = sp.execute(numAdr,nom,prenom);
status = 1;
printMap(results);
} catch (Exception e) {
logger.error("SQL Exception occurred at runStoreProc.", e);
}
return status;
}
private class MyStoreProcedure extends StoredProcedure {
public MyStoreProcedure(DataSource ds, String spName) {
super(ds, spName);
super.setFunction(true);
super.compile();
}
public Map execute(int numAdr, String nom, String prenom) {
Map<String,Object> inParams = new HashMap<String,Object>(3);
inParams.put("numAdr",numAdr);
inParams.put("nom", nom);
inParams.put("prenom", prenom);
return super.execute(inParams);
// the 'sysdate' sproc has no input parameters, so an empty Map is supplied...
//return execute(new HashMap());
}
}
private static void printMap(Map results) {
for (Iterator it = results.entrySet().iterator(); it.hasNext(); ) {
System.out.println(it.next());
}
}
} |
et voici mon fichier de configuration spring-context.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schem...-beans-2.5.xsd" target="_blank">http://www.springframework.org/schem...-beans-2.5.xsd</a>
<a href="http://www.springframework.org/schema/aop" target="_blank">http://www.springframework.org/schema/aop</a> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<!-- Notre implémentation basée sur un SimpleJDBCTemplate
<bean id="testsp" class="avilog.spring.jdbc.test.TestStoredProcedure ">
<property name="jdbcTemplate">
<ref bean="jdbcTemplate" />
</property>
</bean>-->
<!-- SimpleJDBCTemplate
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
<property name = "dataSource" ref = "dataSource" />
</bean> -->
<bean class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:/springjdbc.properties</value>
</property>
</bean>
<!-- <context:component-scan base-package="avilog.spring.jdbc.test"/>-->
<bean id="testDaoImpl" class="avilog.spring.jdbc.test.TestDaoImpl">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- Source de données -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
<property name="driverClassName" value="${springjdbc.driverClassName}"/>
<property name="url" value="${springjdbc.url}"/>
<property name="username" value="${springjdbc.username}"/>
<property name="password" value="${springjdbc.password}"/>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager"
p:dataSource-ref="dataSource"/>
</beans> |
Quelqu'un pourrait il m'aider svp ?