Tôi đã thiết lập một dự án trong Netbeans, đã tạo một tập lệnh, tạo một cơ sở dữ liệu mới với javadb. Tôi có thể kết nối với nó bằng cách gui - hiển thị nội dung bảng vv, nhưng khi tôi chạy một ứng dụng với:Không tìm thấy [org.apache.derby.jdbc.ClientDriver]. Khi cố gắng kết nối với db
EntityManager em = Persistence.createEntityManagerFactory("lab5PU").createEntityManager();
tôi nhận được ngoại lệ khá dài này:
[EL Info]: 2013-04-05 21:40:45.554--ServerSession(1198260109)--EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
[EL Severe]: 2013-04-05 21:40:45.574--ServerSession(1198260109)--Local Exception Stack:
Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [org.apache.derby.jdbc.ClientDriver] not found.
Exception Description: Configuration error. Class [org.apache.derby.jdbc.ClientDriver] not found.
at org.eclipse.persistence.exceptions.DatabaseException.configurationErrorClassNotFound(DatabaseException.java:82)
tôi có thể thấy các trình điều khiển javadb trong phần trình điều khiển trong các dịch vụ, vì vậy tôi không biết có lỗi gì.
EDIT: persistance.xml theo yêu cầu:
<?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="lab5PU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>lab5.Colleagues</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/lab5"/>
<property name="javax.persistence.jdbc.password" value="mypass"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.user" value="admin"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
Địa chỉ kết nối db của bạn được định cấu hình ở đâu? Trong 'persistence.xml'? Bạn có thể hiển thị cấu hình đó không? – pepuch
@ PatrykRoszczyniała đã thêm persistance.xml theo yêu cầu –
Tôi mới trong JEE nhưng trình điều khiển này 'com.mysql.jdbc.Driver' hoạt động cho ứng dụng của tôi. – pepuch