2

What should be the property statement regarding the derby client driver in the persistence.xml e.g :

<property name="javax.persistence.jdbc.driver" value="  ?  " />

When tyring to update the DB from Java I keep getting the exception below.
Actually I need the client driver instead the EmbeddedDriver . Don't know how to name it.
The project has in its java Build path/libraries the Derby Client JDBC driver ( eclipse plugin has the derby plugin). The program instruction causing the exception is :

    factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
    EntityManager em = factory.createEntityManager();


[EL Info]: 2012-02-02 10:48:44.805--ServerSession(1434473856)--EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
[EL Severe]: 2012-02-02 10:48:44.93--ServerSession(1434473856)--Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error.  Class [org.apache.derby.jdbc.EmbeddedDriver] not found.
Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error.  Class [org.apache.derby.jdbc.EmbeddedDriver] not found.
oers
  • 18,436
  • 13
  • 66
  • 75
dubi
  • 51
  • 3
  • 6

1 Answers1

3

javax.persistence.jdbc.driver defines the protocol that shall be used to access the database.

You need to set it like this, if you want to access a remote/local derby network server:

<property name="javax.persistence.jdbc.driver" value="jdbc:derby://localhost:1527/my_schema  " />

Where 1527 is the port of your NetworkServer. And my_schema is your database schema.

If you don't have schema yet, use ;create=true to create it:

jdbc:derby://localhost:1527/my_schema;create=true

You may want to take a look at the Getting Started Guide.

Side note:

Class [org.apache.derby.jdbc.EmbeddedDriver] not found.

This tells you that not all jars needed by derby are present in the classpath(in your comment you state, that this is the case). If you get any such exception, make sure that all jars are actually in the classpath.

oers
  • 18,436
  • 13
  • 66
  • 75
  • @user1183398 please use the edit link under your question to add new/relevant information – oers Feb 02 '12 at 10:15
  • I have thia properties in my persistence file like this: Note I have connection to the DB ( at a remote servre) ,which already exist, via the Eclipse data viewer but fail from my Java JPA project with the above exception. I need know the 'value' of the following item Is this my problem with the above exception or need some other fix? (I used the example from the JPA 2.0 tutorial) – dubi Feb 02 '12 at 10:44
  • @user1183398 if you need to connect to the remote derby server you need to set the value according to my answer (but adapt it to your needs). The embedded driver is not in derbyclient.jar, but you want to use the network client right?. If you need the embedded drievr you need derby.jar – oers Feb 02 '12 at 10:57
  • javax.persistence.jdbc.driver **does not tell the jar** that is needed, it is used to define the jdbc url to! And this depends which database you need to access. This property defines a protokoll. – oers Feb 02 '12 at 11:37