db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajesh Kartha <kar...@Source-Zone.Org>
Subject Re: Opening a database with spaces in a filename
Date Fri, 26 Aug 2005 17:45:48 GMT
Daniel Noll wrote:

>
> I've just discovered that when opening a URL with spaces in it, I get 
> an error like this:
> "Database 'directory:C:\Test\My Databases\Database' not found."
>
> This is on Windows, and trying the same path with short filenames 
> instead, worked.
>
> I've tried:
>    - Using / instead of \
>    - Using %20 to replace the spaces (like normal URL encoding... 
> which would seem reasonable for a URL.)
>    - Both of the above at the same time...
>
> Neither worked.
>
> Directories with spaces in them aren't exactly rare, so my question 
> is, how do I encode a URL for a Derby database?  The developer guide 
> doesn't describe how Derby's URLs are supposed to be encoded.
>
> Daniel
>
Hi Daniel,

The error  above shows 'directory', was that in the url that was used. 
You need to just give the path to the database.
I just tried the following: successfully:

Thru ij:

C:\temp>java org.apache.derby.tools.ij
ij version 10.1
ij> connect 'jdbc:derby:c:\temp\my new dir\a temp\b temp\spdb;create=true';
ij> disconnect;
ij> exit;

C:\temp>java org.apache.derby.tools.ij
ij version 10.1
ij> connect 'jdbc:derby:c:\temp\my new dir\a temp\b temp\spdb';
ij> create table t(id int);
0 rows inserted/updated/deleted
ij> disconnect;
ij> exit;

Thru a small Java program:

try{
            
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
            System.out.println("Driver Loaded");
            Connection 
conn=DriverManager.getConnection("jdbc:derby:c:\\temp\\my new dir\\a 
temp\\b temp\\spdb");
            System.out.println("Connection obtained");
        }catch(Exception e){
            System.out.println("Error "+e);
            e.printStackTrace();
        }

Output:
Driver Loaded
Connection obtained

Both the connections were to the same database..
Can you post more details about the issue you are facing.

-Rajesh




Mime
View raw message