Hi Mamta,
Some comments inline...
On 1/31/14 3:18 PM, Mamta Satoor wrote:
Hi,
I am not familiar with Derby's in memory db implementation (accessed
through jdbc url jdbc:derby:memory:... ) but I thought there will not
be any file system access for such a db. But when I tried a long
dbname with such a url, I got the exception(the complete stack trace
is at the bottom of this email.) "Caused by: java.sql.SQLException:
Java exception: 'The parameter is incorrect.: java.io.IOException'.
The url I tried is
'jdbc:derby:memory:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;create=true';
For the record, that connection url works fine on Mac OSX. Maybe that
long database name is not a legal file name on your file system?
I am copying a little part of the long stack trace to show that
exception is being thrown by windows system api(I am trying this on a
Windows 7 machine)
Caused by: java.io.IOException: The parameter is incorrect.
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:407)
at java.io.File.getCanonicalPath(File.java:570)
at
org.apache.derby.impl.io.VFMemoryStorageFactory.init(VFMemoryStorageFactory.java:109)
In-memory database names are canonicalized just like on-disk database
names. That is, the part after the "memory:" token is treated as a file
name. Relative and absolute file names are equivalent provided that they
identify the same file name. So, on my file system the following two
database names are equivalent:
memory:foo
memory:/Users/rh161140/derby/mainline/foo
Enforcing this equivalence requires Derby to make java.io calls, even
though nothing on disk is actually touched.
Hope this helps,
-Rick
The java comment for VFMemoryStorageFactory.init is as follows. It
looks like we are accessing the file system to make sure there is no
such dbname already existing in the file system. Should we be catching
'The parameter is incorrect.: java.io.IOException' in this code and if
we get this exception, then we can assume that there is no physical db
with the same name and hence we can go ahead and create in memory db.
Appreciate all the help. Thanks
/**
* Initializes the storage factory instance by setting up a temporary
* directory, the database directory and checking if the database
being
* named already exists.
*
* @param home the value of {@code <mailto:%7B@code> system.home}
for this storage factory
* @param databaseName the name of the database, all relative
pathnames are
* relative to this name
* @param tempDirNameIgnored ignored
* @param uniqueName used to determine when the temporary
directory can be
* created, but not to name the temporary directory itself
*
* @exception IOException on an error (unexpected).
*/
Here is the complete stack trace
ERROR XJ040: Failed to start database
'memory:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
with class loader sun.misc.Launcher$AppClassLoader@53745374
<mailto:sun.misc.Launcher$AppClassLoader@53745374>, see the next
exception for details.
java.sql.SQLException: Failed to start database
'memory:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
with class loader sun.misc.Launcher$AppClassLoader@53745374
<mailto:sun.misc.Launcher$AppClassLoader@53745374>, see the next
exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:103)
at
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:137)
at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:310)
at
org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:2842)
at
org.apache.derby.impl.jdbc.EmbedConnection.<init>(EmbedConnection.java:405)
at
org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(InternalDriver.java:628)
at
org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:282)
at
org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:913)
at
org.apache.derby.jdbc.AutoloadedDriver.connect(AutoloadedDriver.java:147)
at java.sql.DriverManager.getConnection(DriverManager.java:419)
at java.sql.DriverManager.getConnection(DriverManager.java:391)
at
org.apache.derby.impl.tools.ij.ij.dynamicConnection(ij.java:1483)
at
org.apache.derby.impl.tools.ij.ij.ConnectStatement(ij.java:1313)
at org.apache.derby.impl.tools.ij.ij.ijStatement(ij.java:1101)
at
org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:347)
at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:245)
at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
at org.apache.derby.tools.ij.main(ij.java:59)
Caused by: java.sql.SQLException: Failed to start database
'memory:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
with class loader sun.misc.Launcher$AppClassLoader@53745374
<mailto:sun.misc.Launcher$AppClassLoader@53745374>, see the next
exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory.java:138)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:73)
... 19 more
Caused by: java.sql.SQLException: Java exception: 'The parameter is
incorrect.: java.io.IOException'.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory.java:138)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:73)
at
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:137)
at org.apache.derby.impl.jdbc.Util.javaException(Util.java:331)
at
org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:2838)
... 16 more
Caused by: java.io.IOException: The parameter is incorrect.
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:407)
at java.io.File.getCanonicalPath(File.java:570)
at
org.apache.derby.impl.io.VFMemoryStorageFactory.init(VFMemoryStorageFactory.java:109)
at
org.apache.derby.impl.services.monitor.StorageFactoryService.privGetStorageFactoryInstance(StorageFactoryService.java:215)
at
org.apache.derby.impl.services.monitor.StorageFactoryService.access$400(StorageFactoryService.java:71)
at
org.apache.derby.impl.services.monitor.StorageFactoryService$12.run(StorageFactoryService.java:958)
at
org.apache.derby.impl.services.monitor.StorageFactoryService$12.run(StorageFactoryService.java:954)
at
java.security.AccessController.doPrivileged(AccessController.java:327)
at
org.apache.derby.impl.services.monitor.StorageFactoryService.getCanonicalServiceName(StorageFactoryService.java:952)
at
org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(BaseMonitor.java:1504)
at
org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(BaseMonitor.java:988)
at
org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Monitor.java:546)
at
org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:2803)
... 16 more
ERROR XJ001: Java exception: 'The parameter is incorrect.:
java.io.IOException'.
java.sql.SQLException: Java exception: 'The parameter is incorrect.:
java.io.IOException'.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:103)
at
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:137)
at org.apache.derby.impl.jdbc.Util.javaException(Util.java:331)
at
org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:2838)
at
org.apache.derby.impl.jdbc.EmbedConnection.<init>(EmbedConnection.java:405)
at
org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(InternalDriver.java:628)
at
org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:282)
at
org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:913)
at
org.apache.derby.jdbc.AutoloadedDriver.connect(AutoloadedDriver.java:147)
at java.sql.DriverManager.getConnection(DriverManager.java:419)
at java.sql.DriverManager.getConnection(DriverManager.java:391)
at
org.apache.derby.impl.tools.ij.ij.dynamicConnection(ij.java:1483)
at
org.apache.derby.impl.tools.ij.ij.ConnectStatement(ij.java:1313)
at org.apache.derby.impl.tools.ij.ij.ijStatement(ij.java:1101)
at
org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:347)
at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:245)
at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
at org.apache.derby.tools.ij.main(ij.java:59)
Caused by: java.sql.SQLException: Java exception: 'The parameter is
incorrect.: java.io.IOException'.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory.java:138)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:73)
... 19 more
Caused by: java.io.IOException: The parameter is incorrect.
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:407)
at java.io.File.getCanonicalPath(File.java:570)
at
org.apache.derby.impl.io.VFMemoryStorageFactory.init(VFMemoryStorageFactory.java:109)
at
org.apache.derby.impl.services.monitor.StorageFactoryService.privGetStorageFactoryInstance(StorageFactoryService.java:215)
at
org.apache.derby.impl.services.monitor.StorageFactoryService.access$400(StorageFactoryService.java:71)
at
org.apache.derby.impl.services.monitor.StorageFactoryService$12.run(StorageFactoryService.java:958)
at
org.apache.derby.impl.services.monitor.StorageFactoryService$12.run(StorageFactoryService.java:954)
at
java.security.AccessController.doPrivileged(AccessController.java:327)
at
org.apache.derby.impl.services.monitor.StorageFactoryService.getCanonicalServiceName(StorageFactoryService.java:952)
at
org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(BaseMonitor.java:1504)
at
org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(BaseMonitor.java:988)
at
org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Monitor.java:546)
at
org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:2803)
... 16 more