Friday, February 12, 2010

Solving EclipseLink-JPA Connection Error: User id length (0) is outside the range of 1 to 255.

While trying to connect to a database with NetBeans 6.8, EclipseLink - JPA, and Apache Derby / Java DB, I get the following error:

 User id length (0) is outside the range of 1 to 255.

It's because a non-empty username is needed for connection. However, I've put a username and the problem persists.

The solve this problem, edit META-INF/persistence.xml and add the following:
    <properties>
      <property name="javax.persistence.jdbc.user" value="APP"/>
      <property name="javax.persistence.jdbc.password" value="APP"/>
     </properties>
Change user and password to your configuration.

Note: The above works only for JPA 2.0-compliant ORM. For proprietary EclipseLink would be:
    <properties>
      <property name="eclipselink.jdbc.user" value="APP"/>
       <property name="eclipselink.jdbc.password" value="APP"/>
    </properties>

Related resources:

1 comment:

  1. Thanks a ton! I'm very new to Java EE and JPA, and you saved a me headaches.

    ReplyDelete