“未知数据库'mydb'”与jpa错误

时间:2010-03-16 10:40:11

标签: java mysql jpa

我正在尝试连接到mysql服务器但收到此错误。当mydb是系统中唯一的名称时。请告诉我我哪里错了......

我的持久性xml如下:

<persistence 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_1_0.xsd"
 version="1.0">

 <persistence-unit name="MyPersistenceUnit">

  <provider>org.hibernate.ejb.HibernatePersistence</provider>

  <properties>
   <property name="hibernate.archive.autodetection" value="class" />
   <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
   <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/mydb" />
   <property name="hibernate.connection.username" value="root" />
   <property name="hibernate.connection.password" value="tft" />
   <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />

   <property name="hibernate.hbm2ddl.auto" value="create" />

   <property name="hibernate.show_sql" value="true" />
   <property name="hibernate.format_sql" value="true" />
   <property name="hibernate.use_sql_comments" value="true" />
  </properties>

 </persistence-unit>
</persistence>

1 个答案:

答案 0 :(得分:0)

1.您必须检查您的mysql jdbc驱动程序

2.你必须检查mysql服务器状态和用户名和验证;密码。