Results 1 to 2 of 2
  1. #1
    Brokkoli3000 is offline Member
    Join Date
    Aug 2016
    Posts
    1
    Rep Power
    0

    Default Java DB with JPA

    High everyone,

    I'm trying to create an application with access to a Java DB database, but for easier use I'd like to include JPA. Trying this out, I used the first implementation I found: glassfish.

    The Java DB itself works, because access via JDBC is possible. But when I try to connect over JPA with the following code...

    Java Code:
    try {
    	Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
    	EntityManagerFactory factory = Persistence.createEntityManagerFactory("QuickStart");
    	EntityManager manager = factory.createEntityManager();
    } catch (Exception ex) {
    	ex.printStackTrace();
    }
    ... I get the following exception:

    Java Code:
    Local Exception Stack: 
    Exception [TOPLINK-4003] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
    Exception Description: Configuration error.  Class [sun.jdbc.odbc.JdbcOdbcDriver] not found.
    	at oracle.toplink.essentials.exceptions.DatabaseException.configurationErrorClassNotFound(DatabaseException.java:101)
    	at oracle.toplink.essentials.sessions.DefaultConnector.loadDriver(DefaultConnector.java:183)
    	at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:98)
    	at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:184)
    	at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
    	at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280)
    	at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229)
    	at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93)
    	at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126)
    	at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:120)
    	at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:91)
    	at startup.DBTest.main(DBTest.java:21)
    But why is the application searching for a JdbcOdbc driver? Do I need it for a Java DB - JPA - interface? And if not, what else is needed and how can I tell it to use it?

    Any idea would be appreciated!

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Java DB with JPA

    How have you set up your persistence unit properly?
    What's the persistence.xml look like?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •