如何在Mac上使用IntelliJ的数据库扩展时访问数据库数据

huangapple go评论53阅读模式
英文:

How to access database data when using database extension in IntelliJ on Mac

问题

I'm trying to implement a MySQL database for my Application I am coding with JavaFX.
我正在尝试为我使用JavaFX编写的应用程序实现MySQL数据库。

My database is all set up and running. I am able to connect to my database and run queries on the database extension (like the database tab in IntelliJ). But I really can't figure out how I could run some queries for let's say a method that should show the output of a query that selects some data from the database.
我的数据库已经设置好并运行。我可以连接到数据库并在数据库扩展中运行查询(类似于IntelliJ中的数据库选项卡)。但我真的不知道如何运行一些查询,比如应该显示从数据库中选择一些数据的方法的输出。

Do I need to create a connection in like a MysqlCon class even though I have one in the database tab?
即使我在数据库选项卡中已经有了一个连接,我是否需要在MysqlCon类中创建一个连接?

When doing that, it can't find the com.mysql.jdbc.Driver in Class.forname(com.myswl.jdbc.Driver). I looked it up and read that putting the jar file in the /Library/Java/Extensions/ folder is not such a great Idea.
这样做时,它无法在Class.forName(com.mysql.jdbc.Driver)中找到com.mysql.jdbc.Driver。我查了一下,并阅读了将jar文件放在/Library/Java/Extensions/文件夹中并不是一个好主意。

Can you guys help me?
你们能帮助我吗?

英文:

I'm trying to implement a MySQL database for my Application I am coding with JavaFX.
My database is all set up and running. I am able to connect to my database and run queries on the database extension (like the database tab in IntelliJ). But I really can't figure out how I could run some queries for let's say a method that should show the output of a query that selects some data from the database.

Do I need to create a connection in like a MysqlCon class even though I have one in the database tab?
When doing that, it can't find the com.mysql.jdbc.Driver in Class.forname(com.myswl.jdbc.Driver). I looked it up and read that putting the jar file in the /Library/Java/Extensions/ folder is not such a great Idea.

Can you guys help me?

答案1

得分: 2

数据库选项卡在IntelliJ IDEA中与您的应用程序无关。它类似于从IDE访问数据库的用户界面。

您需要向您的应用程序添加库。您可以在IntelliJ IDEA内手动添加它们,或者通过构建工具(Maven/Gradle)添加。

英文:

The database tab in IntelliJ IDEA is not related to your application. It's like a UI for accessing databases from the IDE.

You need to add libraries to your app. You can do it manually (inside IntelliJ IDEA), or via the build tool (Maven/Gradle).

huangapple
  • 本文由 发表于 2023年3月9日 23:04:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75686405.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定