英文:
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).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论