“未知的数据库‘MYDB’”使用JPA
问题描述:
错误我试图连接到MySQL服务器,但出现此错误。当mydb是系统中唯一的名称时。请告诉我,我错了......“未知的数据库‘MYDB’”使用JPA
我的坚持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.You要检查你的MySQL JDBC驱动程序
2.You必须检查的MySQL服务器状态并验证用户名为&的密码。
是不是你错了展示的persistence.xml?或者至少,这是我的眼睛告诉我的;-) – Riduidel 2010-03-16 10:49:05
你的数据库起来了吗?你能够使用其他客户端连接吗?什么是完整的异常堆栈跟踪? – saugata 2010-03-16 10:56:14