无法分配连接,因为:用户ID长度(0)超出1到255的范围

我正在使用带有JSF,EJB和JPA的Netbeans创建登录界面。 当我尝试部署项目时,它抛出以下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. 

这是怎么造成的,如何解决?

您需要在persistence.xml中进行配置。

     

看这里

@PSR答案为我做了诀窍,更多内容如下:

netbeans(转载于7.4 build 201310111528)JPA的持久性单元创建向导不强制提供用户名密码。
问题是它不适用于Java DB(德比)。 更大的问题是你得到关于用户id长度的这个尴尬的错误,这是另一个真正没有用的错误消息。

因此,要解决此问题,请使用用户名密码重新创建持久性单元( persistence.xml ),或者在xml中的下手动添加两行:

     

HTH