Results 1 to 4 of 4

Thread: Session factory setup doesn't work

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Posts
    3

    Default Session factory setup doesn't work

    I am evaluating an upgrade of my Spring/Hibernate application from 2.5.6/3.3.2 to 3.2/4.1.9 respectively and have found my database connection no longer works.

    The datasource definition seems to be ignored as I now get this error:

    UnsupportedOperationException: Not supported by BasicDataSource

    I'm using commons-dbcp-1.4 and the error indicates it's looking for username/password.

    If I remove the datasource property and put the datasource properties into the hibernate property, it works fine. unfortunately, I need to encrypt these values via Jasypt and that no longer works either.
    Code:
    <beans>
    
      <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/training1"/>
        <property name="username" value="user1"/>
        <property name="password" value="password1"/>
      </bean>
    
      <bean id="mySessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="myDataSource"/>
        <property name="mappingResources">
          <list>
            <value>product.hbm.xml</value>
          </list>
        </property>
        <property name="hibernateProperties">
          <props>
    	<prop key="hibernate.dialect">
    		org.hibernate.dialect.MySQLInnoDBDialect
    	</prop>
          </props>
        </property>
      </bean>
    
    </beans>
    Anyone else have this problem or am I missing some additional parameters?

    Thank in advance,
    Steven.

  2. #2
    Join Date
    Dec 2012
    Posts
    3

    Default

    No-one has this problem?

    The only way I can get the connection to work is to dispense with the data source and embed all properties as prop keys.

    I cannot get it to work with a data source and it does not work with Spring 3.2; I've gone back to 3.1.3.

    I'd still be interested to know if anyone else encounters this problem.

  3. #3
    Join Date
    Jan 2013
    Posts
    1

    Default

    I think I had this same issue. After diving into Hibernate code, I found it automatically loads properties from the hibernate.properties file. If a username or password is defined there, it attempts to create the connection using them and hits the UnsupportedOperationException.

    So, try renaming hibernate.properties and load it manually if necessary. It worked for me.

  4. #4
    Join Date
    Dec 2012
    Posts
    3

    Default

    Hello ctarczon and thank you for your reply.

    I actually solved it by dispensing with the datastore and putting the hibernate values in the sessionFactory as <prop> entries.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •