Announcement Announcement Module
No announcement yet.
DBCP + IBATIS inserts do not work Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • DBCP + IBATIS inserts do not work

    Is anyone out there using IBATIS + DBCP (I am using with an oracle 9 database).
    When i use Spring to define my DBCP datasource, inserts do not show up in the database, though it is accessing the database and i can get oracle errors if i violate a primary key on the insert. My workaround has been to not define a datasource in Spring and set it in Ibatis sqlconfig file and then it works fine.
    I am not sure how to track down what could be causing this problem as i have no errors.
    And in spring if I use the DriverManagerDataSource or JNDI the inserts do work.

    Any help would be appreciated.


  • #2
    Off the top of my head, your probably have auto-commit set to false


    • #3
      Looks like your transactions aren't committing. What transaction management are you using? It could be that it's only working when you have autocommit on...


      • #4
        Yes, i assumed the issue was the autocommit. I played with autocommit with no success. I am not using any transaction management as this is a very simple insert I am doing in a Junit test. And when i exchange just the DS to either JNDI or the Spring datasource all is fine


        • #5
          Rod, Are there any settings you would recommend that i can play with in DBCP to try to move past this? I really would like to use Spring and not IBATIS for my DataSource.



          • #6
            try again with small sample


            I have made a small example to show my problem:
            Here is the table:
            CREATE TABLE tgr.dummy
            (data VARCHAR2(50))

            here is the sqlmap insert:

            <insert id="dummy" parameterClass="string">
            insert into tgr.dummy

            and here is the code:

            public void insertDummyRequest(String s) {

            try {
            getSqlMapClient().insert("dummy", s);
            catch (SQLException ex) {
            logger.error("Failed to store request "
            + " Error: " + ex.getMessage());


            Here is my settings in the applicationContext.xml:

            <bean id="sqlMap" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
            <property name="configLocation">
            <property name="dataSource">
            <ref local="dbcpDataSource" />


            and the configuration of the datasource is:

            <bean id="dbcpDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName"><value>oracle.jdbc.driver.O racleDriver</value></property>
            <property name="url"><value>string</value></property>
            <property name="username"><value>string</value></property>
            <property name="password"><value>string</value></property>


            if i comment out the line that sets the property of the datasource in the sqlmap and thus it uses the datasource in teh sqlconfig, it works. Alternatively, if i use the DriverManagerDataSource, it works. So, i seems to be some configuration issue of the combination of spring and ibatis and dbcp. I have not seen any clues to this by running in a debugger. Any thoughts?



            • #7
              I think I understand the problem. When i use a datasource from Spring, Spring sets as the transaction manager the external transaction manager, which now requires me to set a transaction manager explicitly in my applicationContext. However, now i am just wondering what i need to do in code, to use the transaction manager.
              Do i need to explicityly use a transaciton manager? All i am trying to do are simple inserts.