Subject Re: [Firebird-Java] With jdbc: how to create a new database
Author David Jencks
On Feb 9, 2005, at 7:37 PM, A.J. Bonnema wrote:

>
> Hi,
>
> I am new to firebird and I want to create a new file from jdbc.
> Currently I am working from a linux box remotely connecting to a
> windows
> box on an unsecured line.

opening port 3050 to the outside world for firebird is to say the least
inadvisable.
>
> What I want to do is connect to firebird as follows:
>
> Connection con = DriverManager.getConnection(
> getUrl(), "userid","password");
> Statement stmt = con.createStatement();
> stmt.execute("create database " + dbName + ";");
>
> The problem currently is the getUrl(). I have tried returning
>
> "jdbc:firebirdsql://hostname/<path-to-new-database>"
> "jdbc:firebirdsql://hostname/<path-to-new-database>/<new-db-name>";
> "jdbc:firebirdsql://hostname";
>
> All cases get me an IO error trying to open the file. This makes sense
> for the first two cases because the files do not exist yet.
> However, for the last case (just the hostname), I expected to be
> connected to the server, without being connected to a specific
> database,
> so I could issue a create-database-statement.
>
> Does anyone know how to do this from jdbc?

You can't do this through jdbc unless things have greatly changed.
However there is a non-jdbc class provided for this kind of thing, IIRC
FbManager. Most of the unit tests (used to) use it to create the db
for the tests. Again, IIRC, firebird won't create directories for you,
just the final database file.

david jencks

>
> Guus.
>
> --
> A.J. Bonnema, Leiden The Netherlands,
> user #328198 (Linux Counter http://counter.li.org)
>
>
>
>