6

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
cloud
  • 173
  • 1
  • 2
  • 8
  • Could you please share the relevant part of the server log? And relevant jsf page and backing bean etc. – Simon Hellinger Mar 15 '13 at 07:27
  • Reading the error, looks like your SQL user is empty... – Alexandre Lavoie Mar 15 '13 at 07:29
  • it seems the User id value that you have given is outside the range of 1 to 255... it is the SQL error – Sathish Mar 15 '13 at 07:31
  • and hv entity class from database which is auto generated sql query, and a simple success and fail jsf jz for display msg purpose – cloud Mar 15 '13 at 08:00
  • Can you give some details about how the database schema is being created? Is it generated automatically, and if so, from which sources? Or did you create it by hand? – mthmulders Mar 15 '13 at 09:06
  • im using the netbean provided databases inside services, i create a database, then use execute command to create all table, and create "entity class from database" inside my project – cloud Mar 15 '13 at 09:53
  • I have cleaned up Engrish in the question and removed all irrelevant JSF/EJB code to reduce noise. They haven't even had the chance to run at all. This is a problem in JPA configuration. Only the `persistence.xml` file is relevant to the problem. Please edit your question to include it and please also try to write like a professional instead of a chatter/texter. E.g. write "I" instead of "i", "have" instead of "hv", and so on. – BalusC Mar 15 '13 at 12:21

3 Answers3

7

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

PSR
  • 39,804
  • 41
  • 111
  • 151
  • 1
    Please edit your answer in such way that it completely answers the question without the need to click off the site to an external site which isn't guaranteed to be still up in the future. Or, if you can't *explain* the problem, just post a comment. This link is already easily found by copypasting the error message into Google. See also http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers – BalusC Mar 15 '13 at 12:26
  • 1
    previously one moderator said.When you are copied answer from another site give reference.Because they did some hard work to get the answer. – PSR Mar 15 '13 at 12:30
4

@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

Hertzel Guinness
  • 5,912
  • 3
  • 38
  • 43
  • Should add that even if you left the user name and password empty, you still need to set the 2 values to APP to make it work – Vahx May 25 '15 at 11:54
0

Often the problem occurs due to an empty string as password, so to solve that you've to mention a '()' in the value attribute of the password, for example if the user is APP and there is no password set, the config would be:

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