我的目标是创建一个本地数据库,可以使用Java进行读写操作。我有一些使用Python操纵本地sqlite数据库以及通过VB.Net与Microsoft Azure上的现有网络数据库交互的经验,但是创建数据库的Java公式却让我无从下手。
大多数来源(例如JDBC文档)似乎都假定您是通过网络协议或在本地主机上托管的数据库来访问数据库。我想要实现的是创建并存储数据库文件(或文件集),以便可以在本地存储和访问,而无需网络连接(可能通过“file:”协议)。 JDBC教程看起来将在我启动后非常有用,但目前超出了我的范围,因为我甚至还没有现有的数据库。
Many sources have suggested solutions like H2, MySQL, Derby, or Hypersonic DB. However, I'm loath to install extensions (if that's the right term) for a number of reasons:
This answer looks close to what I'm aiming for; however, it gives the error:
“jdbc:file://targetFile.sql”也尝试了,但出现了类似的错误。我见过术语“嵌入式”数据库,它是“本地数据库”的一个子集(即本地数据库存储在同一个系统上——嵌入式数据库是仅由单个应用程序使用的本地数据库)。如果我的定义有误,请随时纠正我!
大多数来源(例如JDBC文档)似乎都假定您是通过网络协议或在本地主机上托管的数据库来访问数据库。我想要实现的是创建并存储数据库文件(或文件集),以便可以在本地存储和访问,而无需网络连接(可能通过“file:”协议)。 JDBC教程看起来将在我启动后非常有用,但目前超出了我的范围,因为我甚至还没有现有的数据库。
Many sources have suggested solutions like H2, MySQL, Derby, or Hypersonic DB. However, I'm loath to install extensions (if that's the right term) for a number of reasons:
- This project is initially intended to help me learn my way around Java - widening the scope of the project will dilute my experience with the "base" language and, probably, increase the temptation to engage in "cargo cult programming"
- If this project does ever get distributed to other users (admittedly unlikely, but still!), I don't want to force them into installing more than the core of Java.
- I simply don't know how to install extensions (add-ons? modules?) in Java - one baby-step at a time!
This answer looks close to what I'm aiming for; however, it gives the error:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/?user=root&password=rootpassword
“jdbc:file://targetFile.sql”也尝试了,但出现了类似的错误。我见过术语“嵌入式”数据库,它是“本地数据库”的一个子集(即本地数据库存储在同一个系统上——嵌入式数据库是仅由单个应用程序使用的本地数据库)。如果我的定义有误,请随时纠正我!