java - Intellij Idea JPA 控制台由于“[3D000] 未选择数据库”而无法运行
问题描述
数据源已正确设置,并且可以很好地使用自动完成功能。我没有persistence.xml,因为我正在使用注释。
我在存储库(扩展 CrudRepository)上使用 @Query (native=false) 进行了很多工作,因此使用 JPA 控制台是测试查询的一种非常快速的方法。但是当我尝试在那里运行查询时,我得到:
[3D000] No database selected
我不能在那里使用 USE 保留字。所以我想知道我的配置中可能缺少什么。
解决方案
I also struggled with this and found the solution.
When creating a datasource in IDEA, you can choose to which database you want to connect within that source. When left empty, no database is selected and you'll get the "[3D000] No database selected" error in the JPQL-console.
Instead, create a datasource with default database:
Now, assign this datasource in the Persistence tool window (e.g. View | Tool Windows | Persistence) to your persistence unit:
And:
Now, you should be ready to go!
推荐阅读
- mysql - 从重复行中选择最大的 deleted_data
- javascript - ES6 数组过滤器去除常用项
- python-3.x - 在 Python 中用空格解析 Json 数据
- javascript - 异步 Promise 阻塞 DOM
- css - 用于 Sass 的可扩展的全局变量赋值 @mixin
- python - Python 请求会话不适用于下一次调用中的 put/post
- c++ - 在 C++ 中将内部类实现为具有名称空间的单独类有什么好处?
- node.js - 节点如何处理计算和事件循环
- scala - 如何使用 Cats 组合类型参数边界和仿函数?
- react-native - 如何在图片上方添加文字?