在闪存驱动器上运行 Apache Derby
我正在尝试从闪存驱动器运行 Apache Derby 数据库。我复制了相关的 .jar 文件并设法启动了网络服务器。但是如何指定连接服务器的连接URL呢?数据库位于标记为 G 的闪存驱动器中
。使用以下代码,但遇到异常:
DriverManager.getConnection("jdbc:derby://localhost:1527");
java.sql.SQLException:URL 'jdbc:derby://localhost:1527' 格式不正确。
如何像普通数据库一样连接并使用它?
谢谢你!
I'm trying to run the Apache Derby db from a flash drive. I copied the relevant .jar files and managed to start up the network server. But how to I specify the connection URL in connecting to the server? the database is in the flash drive labeled as G.
Used the following code, but came across an exception:
DriverManager.getConnection("jdbc:derby://localhost:1527");
java.sql.SQLException: The URL 'jdbc:derby://localhost:1527' is not properly formed.
How can I connect and use it as a normal database?
Thank You!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
闪存驱动器的存在对于这个问题来说并不重要。最相关的一点是Derby服务器是运行在嵌入式模式还是网络服务器模式。
从使用的 URL 来看,您似乎打算连接到作为网络服务器运行的 Derby。如果您使用 Derby 安装中提供的
startNetworkServer
shell 脚本启动 Derby,就会出现这种情况。如果是这样,连接 URL 格式,如中定义Derby 文档如下所示。请注意databaseName
参数的存在,该问题中发布的 URL 中缺少该参数。如果您不想以网络服务器模式启动 Derby,而是作为嵌入式数据库启动,则 连接 URL 格式不同。请注意,缺少端口号,并且依赖于值为
directory
、classpath
或jar
之一的子协议。 此格式的示例也可以在文档。The presence of the flash drive is immaterial to this question. The most pertinent point is whether the Derby server is running in the embedded mode or in the network server mode.
From the URL used, it appears that you intend to connect to Derby running as a network server. This would be the case if you've started Derby using the
startNetworkServer
shell scripts, available in the Derby installation. If so, the connection URL format, as defined in the Derby documentation is as shown below. Note the presence of thedatabaseName
parameter, which is missing in the URL posted in the question.If you didn't want to start Derby in the network server mode, but instead as an embedded database, then the connection URL format is different. Note the absence of the port number, and the reliance on a subprotocol whose value are one of
directory
,classpath
orjar
. Examples of this format can also be found in the documentation.