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

前端 未结 3 653
感情败类
感情败类 2021-01-12 19:44

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: ja         


        
相关标签:
3条回答
  • 2021-01-12 20:27

    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>
    
    0 讨论(0)
  • 2021-01-12 20:36

    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

    0 讨论(0)
  • 2021-01-12 20:36

    @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

    0 讨论(0)
提交回复
热议问题