热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

内部异常:java.sql.SQLException:未选择数据库

我知道这个问题在持久性用户中非常普遍.我在许多论坛上访问了很多主题和问题,但仍然没有找到解决方案.我已经从数据库(Netbeans8.0.2中的一个选项)创建了RESTfulWeb

我知道这个问题在持久性用户中非常普遍.我在许多论坛上访问了很多主题和问题,但仍然没有找到解决方案.

我已经从数据库(Netbeans 8.0.2中的一个选项)创建了RESTful Web服务.
我还为该项目创建了连接池和JNDI.正确给出名称,如下所示.

默认情况下使用EclipseLink(JPA 2.1)
我得到这种回应:


GET RequestFailed RequestFailed –> Status: (500)

Response: {

HTTP Status 500 – Internal Server Error

type Exception report

messageInternal Server Error

descriptionThe server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: javax.ejb.EJBException

root cause

javax.ejb.EJBException

root cause

javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services – 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException

Internal Exception: java.sql.SQLException: No database selected

Error Code: 1046

Call: SELECT id, access_expires, access_token, address, bank_account_type, created, device_id, device_type, email, facebook_id, grazie_code, latitude, longitude, password, phone_number, profile_pic, refresh_expires, refresh_token, reg_id, token_created, total_balance, type_work, user_name, user_type FROM users

Query: ReadAllQuery(referenceClass=Users sql=”SELECT id, access_expires, access_token, address, bank_account_type, created, device_id, device_type, email, facebook_id, grazie_code, latitude, longitude, password, phone_number, profile_pic, refresh_expires, refresh_token, reg_id, token_created, total_balance, type_work, user_name, user_type FROM users”)

root cause

Exception [EclipseLink-4002] (Eclipse Persistence Services – 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException

Internal Exception: java.sql.SQLException: No database selected

Error Code: 1046

Call: SELECT id, access_expires, access_token, address, bank_account_type, created, device_id, device_type, email, facebook_id, grazie_code, latitude, longitude, password, phone_number, profile_pic, refresh_expires, refresh_token, reg_id, token_created, total_balance, type_work, user_name, user_type FROM users

Query: ReadAllQuery(referenceClass=Users sql=”SELECT id, access_expires, access_token, address, bank_account_type, created, device_id, device_type, email, facebook_id, grazie_code, latitude, longitude, password, phone_number, profile_pic, refresh_expires, refresh_token, reg_id, token_created, total_balance, type_work, user_name, user_type FROM users”)

root cause

java.sql.SQLException: No database selected

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1 logs.

GlassFish Server Open Source Edition 4.1


我的persistence.xml文件是这样的:



org.eclipse.persistence.jpa.PersistenceProvider
jdbc/dwolla
false
ALL
















Domain.xml:


































解决方法:

我得到了解决方案.您可以看到我已经编辑了glassfish服务器的domain.xml并设置了连接池属性和JNDI.我去了glassfish管理控制台并编辑了连接池,我发现服务器无法识别我所做的更改.它显示了URL属性,例如“ jdbc:mysql://:3306 /”,不知道为什么它没有从domain.xml获取属性,但是现在终于可以了.


推荐阅读
author-avatar
我的双宝宝_486
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有