Announcement Announcement Module
Collapse
No announcement yet.
SimpleJdbcInsert with JNDI Datasource gives ClassCastException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleJdbcInsert with JNDI Datasource gives ClassCastException

    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?

    Code:
            this.insertAvailability = 
                new SimpleJdbcInsert(dataSource).withTableName("MY_TABLE");
    
                        Map<String, Object> parms = new HashMap<String, Object>();
                        etc
                        insertAvailability.execute(parms);
    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:
    java.lang.ClassCastException: $Proxy11
    	at $Proxy10.getTables(Unknown Source)
    	at org.springframework.jdbc.core.metadata.GenericTableMetaDataProvider.locateTableAndProcessMetaData(GenericTableMetaDataProvider.java:269)
    When I replace the use of the SimpleJdbcInsert with SimpleJdbcTemplate, the error has gone:

    Code:
                        jdbcTemplate.update("insert into my_table ("
                                            + "field1, field2, field3)"
                                            + " values (?, ?, ?)"
                                            , x, y, z)
    Due to time constraints I stopped looking, since I got it working, but anybody an idea?
Working...
X