找不到类[org.apache.derby.jdbc.ClientDriver]。尝试连接到db时 [英] Class [org.apache.derby.jdbc.ClientDriver] not found. When trying to connect to db

查看:1651
本文介绍了找不到类[org.apache.derby.jdbc.ClientDriver]。尝试连接到db时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Netbeans中设置了一个项目,创建了一个脚本,使用javadb创建了一个新的数据库。我可以通过gui连接到它 - 显示表内容等,但是当我运行一个应用程序:

I have set up a project in Netbeans, created a script, made a new database with javadb. I can connect to it by gui - display the tables contents etc, but when i run an application with:

 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)

我可以看到在服务驱动程序部分的javadb驱动程序,所以我不知道错误可能是什么。

I can see the javadb drivers in the driver section in services, so i have no idea what the error might be.

编辑:persistance.xml请求: / p>

persistance.xml as requested:

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

推荐答案

我认为你的问题是你没有Derby驱动

I think the problem you have is that you don't have the Derby driver in the classpath of the project.

您可以轻松地实现将JavaDB库添加到您的项目:

You can easily achieve that adding the JavaDB library to your project:


  • 右键单击项目

  • 属性 - >库

  • 添加库 - > JavaDB驱动程序

这包括 derby.jar derbyclient.jar

This includes derby.jar, derbyclient.jar and derbynet.jar in your project's classpath.

derbyclient.jar 包含类 org.apache.derby.jdbc.ClientDriver 您的代码正在抱怨。

The derbyclient.jar contains the class org.apache.derby.jdbc.ClientDriver your code is complaining about.

这篇关于找不到类[org.apache.derby.jdbc.ClientDriver]。尝试连接到db时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆