简体   繁体   English

未找到类[org.apache.derby.jdbc.ClientDriver]。 尝试连接到db时

[英]Class [org.apache.derby.jdbc.ClientDriver] not found. When trying to connect to db

I have set up a project in Netbeans, created a script, made a new database with javadb. 我在Netbeans中建立了一个项目,创建了一个脚本,用javadb建立了一个新的数据库。 I can connect to it by gui - display the tables contents etc, but when i run an application with: 我可以通过gui连接到它 - 显示表内容等,但当我运行一个应用程序时:

 EntityManager em = Persistence.createEntityManagerFactory("lab5PU").createEntityManager();

i get this quite long exception: 我得到这个很长的例外:

[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)

I can see the javadb drivers in the driver section in services, so i have no idea what the error might be. 我可以在服务的驱动程序部分看到javadb驱动程序,所以我不知道错误是什么。

EDIT: persistance.xml as requested: 编辑:persistance.xml按要求:

<?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>

在此输入图像描述

I think the problem you have is that you don't have the Derby driver in the classpath of the project. 我认为你遇到的问题是你没有在项目的类路径中使用Derby驱动程序。

You can easily achieve that adding the JavaDB library to your project: 您可以轻松实现将JavaDB库添加到项目中:

  • Right-click on the project 右键单击该项目
  • Properties -> Libraries 属性 - >库
  • Add Library -> JavaDB driver 添加库 - > JavaDB驱动程序

This includes derby.jar , derbyclient.jar and derbynet.jar in your project's classpath. 这包括项目类路径中的derby.jarderbyclient.jarderbynet.jar

The derbyclient.jar contains the class org.apache.derby.jdbc.ClientDriver your code is complaining about. derbyclient.jar包含您的代码抱怨的org.apache.derby.jdbc.ClientDriver类。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java-找不到类[org.apache.derby.jdbc.ClientDriver] - java - Class [org.apache.derby.jdbc.ClientDriver] not found org.apache.derby.jdbc.ClientDriver ; 无法连接 - org.apache.derby.jdbc.ClientDriver ; unable to connect org.apache.derby.jdbc.ClientDriver 在哪里? - where is org.apache.derby.jdbc.ClientDriver? 无法使用org.apache.derby.jdbc.ClientDriver建立与MySQL的连接 - Cannot establish connection to MySQL using org.apache.derby.jdbc.ClientDriver 日志中的Heroku错误:java.lang.ClassNotFoundException:org.apache.derby.jdbc.ClientDriver - Heroku error in logs: java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver 创建数据库时出错:java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver - An error occurred while creating the database: java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver 线程“主”java.lang.ClassNotFoundException 中的异常:org.apache.derby.jdbc.ClientDriver - Exception in thread “main” java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver 尝试设置Java DB:“未找到类:无法加载JDBC驱动程序org.apache.derby.jdbc.EmbeddedDriver” - Trying to set up Java DB: “Class Not Found: JDBC driver org.apache.derby.jdbc.EmbeddedDriver could not be loaded” 配置错误。 连接到数据库时找不到类 [org.apache.derby.jdbc.EmbeddedDriver] - Configuration error. Class [org.apache.derby.jdbc.EmbeddedDriver] not found while connecting to DB 尝试将JPA与Derby一起使用时ClassNotFoundException:org.apache.derby.jdbc.EmbeddedDriver - ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver when trying to use JPA with Derby
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM