mercredi 4 mars 2015

JDBC TransientDataAccessResourceException

I have the next class:



public class Student {
private ApplicationContext ctx=new ClassPathXmlApplicationContext("beans.xml");
private DataSource ds=(DataSource)ctx.getBean("mainDataSource");
private JdbcTemplate dba=new JdbcTemplate(ds);

public void getName(int id){
SqlParameterSource sps=new MapSqlParameterSource().addValue("idStudent", id);
String nume=dba.queryForObject("SELECT name FROM meditator.student WHERE idStudent=:idStudent", String.class, sps);
System.out.println(nume);
}
}


Why I get the next exception?.



Exception in thread "main" org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT nume FROM meditator.student WHERE idStudent=:idStudent]; Invalid argument value: java.io.NotSerializableException; nested exception is java.sql.SQLException: Invalid argument value: java.io.NotSerializableException


Thank you!


Aucun commentaire:

Enregistrer un commentaire