0
我正面臨一個奇怪的問題。我正在使用Hibernate並嘗試使用Hibernate框架運行示例數據庫更新代碼。我正在使用MySQL數據庫@localhost:3306。模式的名稱是「hibernate_test」。由於MySQLSyntaxErrorException,無法通過休眠連接到MySQL數據庫:未知數據庫'dbname'錯誤
我創建了一個名爲 「employee_details」 與下面列的表:
僱員,名字,SecondName。
下面是配置@ hibernate.cfg.xml中
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name = "hbm2ddl.auto">create</property>
<property name = "dialect">org.hibernate.dialect.MySQLDialect</property>
<property name = "connection.url">jdbc:mysql://localhost:3306/hibernate_test"</property>
<property name = "connection.username">root</property>
<property name = "connection.password">mysql123</property>
<property name = "connection.driver_class">com.mysql.jdbc.Driver</property>
<mapping resource="employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
這是我的Hibernate映射代碼:
<hibernate-mapping>
<class name = "com.somnath.test.Employee" table = "employee_details">
<id name = "employeeID">
<generator class ="assigned"></generator>
</id>
<property name="firstName"></property>
<property name="lastName"></property>
</class>
</hibernate-mapping>
運行應用程序時我收到以下錯誤:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'hibernate_test"'
我不知道我在做錯的地方。正如我已經搜索了許多關於這個問題的類似問題,但還沒有得到任何有效的解決方案。
謝謝曼..一個非常非常愚蠢的錯誤從我..非常感謝。 :) – Som