Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection could not be allocated because: User id length (0) is outside the range of 1 to 255

Tags:

java

jpa

netbeans

I'm creating a login interface using Netbeans with JSF, EJB and JPA. When I try to deploy the project, it throws the below exception:

Internal Exception: java.sql.SQLException: 
Error in allocating a connection. Cause: Connection could not be allocated because: User id length (0) is outside the range of 1 to 255.
Error Code: 0. Please see server.log for more details.
C:\Users\Dell\Desktop\assignmenttask2\nbproject\build-impl.xml:1033: The module has not been deployed.
See the server log for details.

How is this caused and how can I solve it?

like image 604
cloud Avatar asked Mar 15 '13 07:03

cloud


2 Answers

you need to configure in persistence.xml .

<properties>
  <property name="javax.persistence.jdbc.user" value="APP"/>
  <property name="javax.persistence.jdbc.password" value="APP"/>
 </properties>

see here

like image 84
PSR Avatar answered Sep 18 '22 23:09

PSR


@PSR answer's did the trick for me, here's more on that:

netbeans (reproduced on 7.4 build 201310111528) JPA's persistance unit creation wizard does not enforce giving a username password.
Problem is it does not work with Java DB (derby). Bigger problem that you get this awkward error regarding user id length, which is another one of those really-not-helpful error messages.

So, to solve this, either recreate the persistence unit (persistence.xml) with a user name password, or add the two lines manually under <properites> in the xml:

<properties>
  <property name="javax.persistence.jdbc.user" value="APP"/>
  <property name="javax.persistence.jdbc.password" value="APP"/>
 </properties>

HTH

like image 40
Hertzel Guinness Avatar answered Sep 21 '22 23:09

Hertzel Guinness