User must provide JDBC connection

I have a file DispactherServlet.xml

that has a hibernate file configuration as

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="mappingResources">
        <list>
            <value>com/dibya/hbm/resource/model.hbm.xml</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.username">root</prop>
            <prop key="hibernate.password"></prop>
            <prop key="hibernate.url">jdbc:mysql://localhost/test</prop>
            <prop key="hibernate.driver_class">com.mysql.jdbc.Driver</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
        </props>
    </property>
</bean>

<bean id = "hibernateTemplate" class = "org.springframework.orm.hibernate3.HibernateTemplate">
    <property name = "persister">
        <ref bean = "sessionFactory"/>
    </property>
</bean>

      

In my controller, I have

@RequestMapping(value = "Hello.htm")
public String HelloWorld(Model model) {
    boolean is = persister.isAllowCreate();

    Person person = new Person();
    person.setName("dibya");
    persister.saveOrUpdate(person);

    System.out.println("This is called"+is);
    return "HelloWorld";
}

      

I am getting this error message:

HTTP Status 500 - Request processing failed; nested exception is java.lang.UnsupportedOperationException: The user must supply a JDBC connection

      

Please tell me what I forget to add.

+3


source to share


2 answers


Incorrect parameter names are used in the hibernate config file. The correct parameter names are shown below:

hibernate.connection.driver_class
hibernate.connection.url
hibernate.connection.username
hibernate.connection.password
hibernate.dialect
hibernate.show_sql

      



Correct your parameter names and try again.

EDIT: Please refer to this link for a detailed list of parameter names: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html

+4


source


You can set up like this:



<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="hibernateProperties">
            <props>

                <prop key="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</prop>
                <prop key="hibernate.connection.url">jdbc:hsqldb:file:/local/hsqldb</prop>
                <prop key="hibernate.connection.username">sa</prop>
                <prop key="hibernate.connection.password"></prop>


                <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
                <prop key="hibernate.show_sql">${gloss.database.hibernate.show_sql}</prop>
                <prop key="hibernate.order_inserts">true</prop>
                <prop key="hibernate.order_updates">true</prop>
                <prop key="hibernate.jdbc.batch_size">100</prop>
                <prop key="hibernate.hbm2ddl.auto">validate</prop>

            </props>
        </property>

        <property name="mappingResources">
            <list>
                <value>com/core/domain/User.hbm.xml</value>
            </list>
        </property>
    </bean>

      

0


source







All Articles