与 java 程序一起使用的最佳数据库是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1082097/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the best database to use with a java program?
提问by Eric Wilson
I've been struggling to get a Java program to connect to MS SQL Server, and I'm starting to wonder if MySQL would be a better choice for my (learning) project.
我一直在努力让 Java 程序连接到 MS SQL Server,我开始怀疑 MySQL 是否是我的(学习)项目的更好选择。
Sun's tutorials refer to Java DB, but I've never heard of that in any other context, so it seems not the most useful database to learn about.
Sun 的教程提到了 Java DB,但我从未在任何其他上下文中听说过,因此它似乎不是最值得学习的数据库。
I appreciate any insight into the most natural way to connect Java to a commonly used database.
我很欣赏任何有关将 Java 连接到常用数据库的最自然方式的见解。
采纳答案by Mykola Golubyev
The kind or the name of Database won't affect your education process as you will work with JDBC.
数据库的种类或名称不会影响您的教育过程,因为您将使用 JDBC。
I think you can go with any. Just set up it in the proper way on your machine and connect with appropriate connection string.
我想你可以和任何人一起去。只需在您的机器上以正确的方式设置它并使用适当的连接字符串连接。
回答by Greg Hewgill
Perhaps you could describe the problems you've been having with connecting to MS SQL. Of course it's possible, so it's likely something small that you have or have not done that's preventing the connection from working.
也许您可以描述连接到 MS SQL 时遇到的问题。当然这是可能的,所以很可能是你做过或没有做过的一些小事情阻止了连接工作。
There are many open source database servers with JDBC drivers. One that you might consider is HSQLDBwhich has a completely in-memory mode so you don't even have to think about setting up a server. This is probably a great way to learn the basics of SQL.
有许多带有 JDBC 驱动程序的开源数据库服务器。您可能考虑的是HSQLDB,它具有完全内存模式,因此您甚至不必考虑设置服务器。这可能是学习 SQL 基础知识的好方法。
回答by Prabhu R
You could try either PostgreSQLor MySQL
您可以尝试使用PostgreSQL或MySQL
回答by kgrad
回答by tomtom
I recommend MySQL or Oracle. From Oracle you can get free database as well, however size of the database is limited.
我推荐 MySQL 或 Oracle。您也可以从 Oracle 获得免费数据库,但数据库的大小是有限的。
Reasoning for this is that those are most used databases and it's good to get some visibility for those. Use JDBC and it's similar interface, but doing code on top of the database and there are other things you need to learn as well. Especially if you do any application which is bit more complex. Also getting hands dirty with basic operations with database is always good.
这样做的原因是那些是最常用的数据库,最好对这些数据库有一定的了解。使用 JDBC 和它的类似接口,但是在数据库之上编写代码,还有其他一些你需要学习的东西。特别是如果您执行任何更复杂的应用程序。此外,熟悉数据库的基本操作总是好的。
回答by John Doe
Microsoft even has documentation on its website. Google keywords were "jdbc sql server".
微软甚至在其网站上都有文档。谷歌关键字是“jdbc sql server”。
回答by lavinio
If you want to stay in Java, one option is Berkeley DB Java Edition. It's the same BDB software that was from Sleepycat, which had a sterling reputation in the embedded database market.
如果您想继续使用 Java,一种选择是Berkeley DB Java Edition。它与来自 Sleepycat 的 BDB 软件相同,后者在嵌入式数据库市场享有盛誉。
回答by Joshua
Pick one database that you can figure out how to install. Most are pretty easy and it will give you a good idea of what using a database is like. Once you have a working app, try porting it to another database. I would recommend using JavaDB for the first one and then one of the other db - Oracle, MySQL, Postgres, etc.
选择一个您可以弄清楚如何安装的数据库。大多数都非常简单,它会让您对使用数据库的方式有一个很好的了解。一旦你有了一个可用的应用程序,尝试将它移植到另一个数据库。我建议第一个使用 JavaDB,然后使用其他数据库之一 - Oracle、MySQL、Postgres 等。
回答by Tim Howland
The biggest issue that I've had with using MSSql is when using the antiquated JDBC -> ODBC Bridge drivers; these do a half-assed Java wrapper around the ODBC calls, which are flaky and fragile. If you are using JDBC ODBC Bridge, replace them with the latest native JDBC drivers from microsoft- they work a million times better.
我在使用 MSSql 时遇到的最大问题是使用过时的 JDBC -> ODBC Bridge 驱动程序;这些围绕 ODBC 调用做了一个半途而废的 Java 包装器,这些调用是易碎和脆弱的。如果您正在使用 JDBC ODBC 桥接器,请将它们替换为来自微软的最新本机 JDBC 驱动程序——它们的工作效率提高了一百万倍。
回答by Thorbj?rn Ravn Andersen
Java DB is Apache Derby rebranded and included in the JDK. It is ok, and it is much easier to install than natively running databases.
Java DB 是 Apache Derby 重新命名并包含在 JDK 中。没关系,而且安装比本地运行的数据库容易得多。
It is very important to use a good driver to the database! That might solve all your connection problems.
对数据库使用一个好的驱动是很重要的!这可能会解决您所有的连接问题。
Also note that if you switch database, you most likely also need to change your SQL unless you use a layer like Hibernate or JPA.
另请注意,如果您切换数据库,您很可能还需要更改 SQL,除非您使用 Hibernate 或 JPA 等层。