erro_persistence_mysql8.0_hibernate_eclipse

Asked

Viewed 72 times

-2

Guys, I’m in my first persistence class, but the code is not working,

**mysql persistence file:*

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">`

    <persistence-unit name="exemploPU" transaction-type="RESOURCE_LOCAL">

        <properties>
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/cadastro_cliente"/>
            <property name="javax.persistence.jdbc.user" value="root"/>
            <property name="javax.persistence.jdbc.password" value="root"/>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>

            <!-- validate | update | create | create-drop -->
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
        </properties>

    </persistence-unit>

</persistence>

1 answer

0


chatting with a DBA teacher identified that the version of Hibernate was incompatible with Mysql Bank, and he adjusted the code on behalf of Timezone:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
</code><code>   
<persistence-unit name="exemploPU" transaction-type="RESOURCE_LOCAL">

        <properties>

            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/cadastro_cliente?serverTimezone=UTC" />
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="root" />

            <!-- validate | update | create | create-drop -->
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
            </properties>
        </persistence-unit>
</persistence>
  • @ngueno vlw by the help in formatting, I was not able to adjust, but as needed help in the code I posted that way. in the next I improve the formatting of it.

  • Don’t worry, it takes getting used to :) one thing you should always do is replace tabs with spaces, tabs mess up all the formatting

  • I get it, this is why the formatting was misaligned ? the use of TAB ? because I could not put all code inside the block.

  • yes, it breaks all tags, another thing is to paste the whole text normally, select the part of code and then mark it as code using the editor button

  • Blza, thank you very much!!!

  • You’re welcome, you’re welcome :)

  • @Henrique.marques Here are some formatting tips: https://answall.com/editing-help#code

  • @hkotsubo, vlw.... I think this is the link I saw, thank you very much for your attention.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.