Announcement Announcement Module
Collapse
No announcement yet.
set autocommit off is not longer suported - Spring + Hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • set autocommit off is not longer suported - Spring + Hibernate

    PLEASE, HELP!

    im starting whit spring and hibernate.... the hibernate properties are defined into applicationContext-hibernate.xml

    ------- applicationContext-hibernate.xml ------
    <!-- Configurer that replaces ${...} placeholders with values from a properties file -->
    <!-- (in this case, JDBC-related settings for the dataSource definition below) -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location" value="/WEB-INF/hibernate.properties"/>
    </bean>

    <!-- Local DataSource that works in any environment -->
    <!-- Note that DriverManagerDataSource does not pool; it is not intended for production -->

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
    </bean>

    <!-- Hibernate SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
    <list>
    <value>user.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.generate_statistics">true</prop>
    <prop key="hibernate.connection.autocommit">true</prop>
    </props>
    </property>
    <property name="eventListeners">
    <map>
    <entry key="merge">
    <bean class="org.springframework.orm.hibernate3.support. IdTransferringMergeEventListener"/>
    </entry>
    </map>
    </property>
    </bean>
    --------------------------------------------

    ------------------ hibernate.properties ---------------------

    # Properties file with JDBC-related settings.
    # Applied by PropertyPlaceholderConfigurer
    # from "applicationContext-hibernate.xml".

    jdbc.driverClassName=org.postgresql.Driver
    jdbc.url=jdbcostgresql://150.162.27.56:5432/banco
    jdbc.username=user
    jdbc.password=senha
    hibernate.dialect=org.hibernate.dialect.PostgreSQL Dialect

    ----------------------------------------

    meanwhile, every time a transaction is executed (ex: getTemplate().doSave()), the error is thrown:

    java.sql.SQLException: ERROR: SET AUTOCOMMIT TO OFF is no longer supported

    I went to de PostgreSQL drive site (http://jdbc.postgresql.org/download.html), and put it the drive (postgresql-8.0-314.jdbc3) in lib directory. But, when I start the TOMCAT, this happens:

    19/12/2005 12:55:27 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: RDBMS: PostgreSQL, version: 8.0.3
    19/12/2005 12:55:27 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 7.3.4 JDBC3 jdbc driver build 113

    I think so that TomCat was loading the wrong driver... how can I change this?????
    How the SPRING wrap the hibernate, i dont know what to do... (when a try first without the SPRING, HIBERNATE have no problems).

    PLEASE, i neeed HELP.
    TANKS A LOT!
    CARVO

  • #2
    Ok I just solved this after some struggle so here's my 2c. Firstly, if you are using postgresql, the problem is definitely that you have a version of the driver that is too old. If you are running version 7.4 of postgres you need pg74.216.jdbc4.jar from http://jdbc.postgresql.org/download.html

    If it still doesn't work, look for the following line in your log file during server startup:

    18173 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 7.4.5 JDBC3 with SSL (build 216)

    If you do not see this message, you have cached the wrong driver somewhere. In my case I am using myeclipse, and it actually deployed the old version to a few places in the .deployable directory since the jar was lying in $TOMCAT_HOME/common/lib. Search and delete it from anywhere you find it!

    Comment

    Working...
    X