Connection cannot be null when 'hibernate.dialect' not set

后端 未结 15 1642
悲&欢浪女
悲&欢浪女 2020-12-16 11:12

having more issues with seting up hibernate with spring3. this time it is saying that connection is nul as the dialect is not set which it is on my hibernate.cfg.xml file.

相关标签:
15条回答
  • 2020-12-16 11:30

    I had the same problem. Switching from the Apache Commons DataSource:

    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="${database.driver}" />
        <property name="url" value="${database.url}" />
        <property name="username" value="${database.user}" />
        <property name="password" value="${database.password} " />
    </bean>
    

    To C3P0:

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="com.mysql.jdbc.Driver" />
        <property name="jdbcUrl" value="jdbc:mysql://ipadress:3306/schema" />
        <property name="user" value="root" />
        <property name="password" value="abc" />
    </bean>
    

    made my problem go away. Maybe someone can explain why, I am just happy it works and wanna share what little I know :)

    0 讨论(0)
  • 2020-12-16 11:32

    The database connection is missing. Add to your hibernate.cfg.xml file a lines like this

    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url">
        jdbc:mysql://localhost:3306/your_database
    </property>
    <property name="connection.username">your_user</property>
    <property name="connection.password">your_password</property>
    

    (replace localhost if the database is not installed on your computer, and set the values beginning with your_ in my example).

    0 讨论(0)
  • 2020-12-16 11:37

    This issue comes if your mysql-connector version and mysql-installer version is different.

    Internally it will throw Caused by:

    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client.

    So you need make your mysql-connector version and mysql-installer version same...

    0 讨论(0)
提交回复
热议问题