-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Using jdbc.properties with Spring/Hibernate
PostPosted: Tue Apr 17, 2012 8:16 am 
Newbie

Joined: Tue Apr 17, 2012 8:04 am
Posts: 1
I am getting the following error while trying to pass in values from a properties file. Is there a better (and correct) approach? I know that the properties file is being referenced because if I put in in invalid password, it fails on that. I'd be grateful for any help. I am adverse to putting values directly in XML, and prefer a properties file.
Code:
WARNING: No connection properties specified - the user must supply JDBC connections
Exception in thread "main" org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
   at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)


This is my Spring applicationContext file.

Code:
<context:component-scan base-package="cmsutil"/>
    <context:property-placeholder location="jdbc.properties"/>

    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.url}"
          p:username="${jdbc.username}"
          p:password="${jdbc.password}"/>

    <bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
          p:dataSource-ref="dataSource"
          p:configurationClass="org.hibernate.cfg.AnnotationConfiguration"
          p:packagesToScan="cmsutil.*">
             
             
        <property name="exposeTransactionAwareSessionFactory" value="false" />
             
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
                <prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
            </props>
        </property>
    </bean>



    <bean id="txnManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"
          p:sessionFactory-ref="sessionFactory"/>
         
    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>


And last but not least - hibernate.cfg.xml. It is located in the root .

Code:
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <mapping resource="cmsutil.entity/contentcomponent.hbm.xml"/>
  </session-factory>
</hibernate-configuration>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.