简体   繁体   English

Derby客户端jdbc驱动程序连接错误:无法创建数据库'sample'

[英]Derby client jdbc driver connection error : Failed to create database 'sample'

I started the Derby Network Server like stated in this tutorial - here . 我启动了本教程中所述的Derby Network Server - 这里

But when i typed: 但是当我键入:

ij>  connect 'jdbc:derby://localhost:1527/sample;create=true',

I get the following error: 我收到以下错误:

ERROR XJ041: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Faile d to create database 'sample', see the next exception for details.::SQLSTATE: XB M0H 错误XJ041:DERBY SQL错误:ERRORCODE:40000,SQLSTATE:XJ041,SQLERRMC:故意创建数据库'sample',详细信息请参见下一个异常。::: SQLSTATE:XB M0H

Any ideas how to fix this ? 任何想法如何解决这一问题 ?

derby.log contents: derby.log内容:

Tue Oct 13 10:56:03 EEST 2015 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1527
Tue Oct 13 10:56:10 EEST 2015 Thread[DRDAConnThread_2,5,main] Cleanup action starting
ERROR XBM0H: Directory C:\Program Files\Java\jdk1.8.0_45\db\bin\sample cannot be created.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.services.monitor.StorageFactoryService$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.derby.impl.services.monitor.StorageFactoryService.createServiceRoot(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.createPersistentService(Unknown Source)
at org.apache.derby.impl.services.monitor.FileMonitor.createPersistentService(Unknown Source)
at org.apache.derby.iapi.services.monitor.Monitor.createPersistentService(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.createDatabase(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source)
at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
Cleanup action completed
Tue Oct 13 10:56:10 EEST 2015 Thread[DRDAConnThread_2,5,main] Cleanup action starting
java.sql.SQLException: Failed to create database 'sample', see the next exception for details.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.createDatabase(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source)
at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
Caused by: ERROR XJ041: Failed to create database 'sample', see the next exception for details.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 16 more
Caused by: ERROR XBM0H: Directory C:\Program Files\Java\jdk1.8.0_45\db\bin\sample cannot be created.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.services.monitor.StorageFactoryService$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.derby.impl.services.monitor.StorageFactoryService.createServiceRoot(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.createPersistentService(Unknown Source)
at org.apache.derby.impl.services.monitor.FileMonitor.createPersistentService(Unknown Source)
at org.apache.derby.iapi.services.monitor.Monitor.createPersistentService(Unknown Source)
... 13 more
============= begin nested exception, level (1) ===========
java.sql.SQLException: Directory C:\Program Files\Java\jdk1.8.0_45\db\bin\sample cannot be created.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.createDatabase(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source)
at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
Caused by: ERROR XBM0H: Directory C:\Program Files\Java\jdk1.8.0_45\db\bin\sample cannot be created.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.services.monitor.StorageFactoryService$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.derby.impl.services.monitor.StorageFactoryService.createServiceRoot(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.createPersistentService(Unknown Source)
at org.apache.derby.impl.services.monitor.FileMonitor.createPersistentService(Unknown Source)
at org.apache.derby.iapi.services.monitor.Monitor.createPersistentService(Unknown Source)
... 13 more
============= end nested exception, level (1) ===========
============= begin nested exception, level (2) ===========
ERROR XBM0H: Directory C:\Program Files\Java\jdk1.8.0_45\db\bin\sample cannot be created.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.services.monitor.StorageFactoryService$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.derby.impl.services.monitor.StorageFactoryService.createServiceRoot(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.createPersistentService(Unknown Source)
at org.apache.derby.impl.services.monitor.FileMonitor.createPersistentService(Unknown Source)
at org.apache.derby.iapi.services.monitor.Monitor.createPersistentService(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.createDatabase(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source)
at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
============= end nested exception, level (2) ===========
Cleanup action completed
Tue Oct 13 10:56:10 EEST 2015 Thread[DRDAConnThread_2,5,main] (DATABASE = sample), (DRDAID = {1}), Failed to create database 'sample', see the next exception for details.
Tue Oct 13 10:56:10 EEST 2015 Thread[DRDAConnThread_2,5,main] (DATABASE = sample), (DRDAID = {1}), Directory C:\Program Files\Java\jdk1.8.0_45\db\bin\sample cannot be created.

The log entry states: 日志条目指出:

Directory C:\\Program Files\\Java\\jdk1.8.0_45\\db\\bin\\sample cannot be created 无法创建目录C:\\ Program Files \\ Java \\ jdk1.8.0_45 \\ db \\ bin \\ sample

So as far as I know this could be some permission issue with network server process not having enough rights to create a directory in C:\\Program Files\\Java\\jdk1.8.0_45\\db\\bin\\ . 因此,据我所知,这可能是network server进程没有足够权限在C:\\Program Files\\Java\\jdk1.8.0_45\\db\\bin\\创建目录的一些权限问题。 You can try to run it as administrator. 您可以尝试以管理员身份运行它。

From your exception stack trace it looks like your Derby network server process was started in the folder C:\\Program Files\\Java\\jdk1.8.0_45\\db\\bin\\ and the process does not seem to have the privileges to write the (Derby database) files in that folder. 从您的异常堆栈跟踪看起来您的Derby网络服务器进程在文件夹C:\\Program Files\\Java\\jdk1.8.0_45\\db\\bin\\并且该进程似乎没有写入(Derby)的权限数据库)该文件夹中的文件。 Try to find a folder where the Derby server process has the privilege to write files into. 尝试查找Derby服务器进程有权将文件写入的文件夹。 You can give specify windows drive letters and paths in the Derby connect URL. 您可以在Derby连接URL中指定Windows驱动器盘符和路径。 Just make sure to convert any back slashes \\ to forward slashes / or escape them like this \\\\ . 只要确保将任何反斜杠\\为正斜杠/或逃避他们这样\\\\ So if for example if you know the Derby server process can write to d:\\temp folder, then you can compose your command as 因此,例如,如果您知道Derby服务器进程可以写入d:\\ temp文件夹,那么您可以将命令编写为

ij> connect jdbc:derby://localhost:1527/d:/temp/sample;create=true

or 要么

ij> connect jdbc:derby://localhost:1527/d:\\\\temp\\\\sample;create=true

Beware substituted drives when using Derby - if you put your database on a substituted drive it won't work and you get confusing nio exceptions and class cast errors in the log. 使用Derby时要小心替换驱动器 - 如果将数据库放在替代驱动器上它将无法工作,并且您会在日志中混淆nio异常和类转换错误。 So this does not work: 所以这工作:

connect 'jdbc:derby://localhost:1527/t:/DerbyDB;create=true';

where t is substituted. 其中t被替换。 The same command pointed at drive c does work: 指向驱动器c的相同命令确实有效:

connect 'jdbc:derby://localhost:1527/c:/DerbyDB;create=true';

There is a discussion of these issues on the Derby site, - but maybe its not fixed for all cases? 在Derby网站上讨论了这些问题,但是对于所有情况都可能没有修复? including where the database itself is on a substituted drive. 包括数据库本身在替代驱动器上的位置。 I'm currently using version 10.10.2.0 我目前正在使用版本10.10.2.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM