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:
      <property name="javax.persistence.jdbc.user" value="APP"/>
      <property name="javax.persistence.jdbc.password" value="APP"/>
Change user and password to your configuration.

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

Related resources: