My standalone java app looks up a JNDI Datasource, defined in a JBoss application server. I use spring 2.5.6, which has a nice SimpleJdbcInsert class.
The use of the JNDI Datasource works when I use the SimpleJdbcTemplate, but not with the SimpleJdbcInsert. The last one gives a ClassCastException. Ofcourse I can work around it, because with the SimpleJdbcTemplate you can do inserts as well, but maybe it's a bug?
Above code works with a locally defined DataSource, but not with a JNDI DataSource, defined in a JBoss 4.3. environment, then it throws:Code:this.insertAvailability = new SimpleJdbcInsert(dataSource).withTableName("MY_TABLE"); Map<String, Object> parms = new HashMap<String, Object>(); etc insertAvailability.execute(parms);
When I replace the use of the SimpleJdbcInsert with SimpleJdbcTemplate, the error has gone:Code:java.lang.ClassCastException: $Proxy11 at $Proxy10.getTables(Unknown Source) at org.springframework.jdbc.core.metadata.GenericTableMetaDataProvider.locateTableAndProcessMetaData(GenericTableMetaDataProvider.java:269)
Due to time constraints I stopped looking, since I got it working, but anybody an idea?Code:jdbcTemplate.update("insert into my_table (" + "field1, field2, field3)" + " values (?, ?, ?)" , x, y, z)


Reply With Quote
