Subject Re: With jdbc: how to create a new database
Author rfincher2000
Hi A.J.,

The format of the URL should be:

jdbc:firebirdsql:[//host[:port]/]<database>

Your example:

jdbc:firebirdsql://hostname/<path-to-new-database>/<new-db-name>

Should be:

jdbc:firebirdsql://hostname:3050/<path-to-new-database>/<new-db-name>

David is right about the security issue. You can either set up a
secure pipe for port 3050 (using ssh or other solutions), or run a
simple web app with HTTPS on the database server using a simple app
server like Tomcat, or a full blown J2EE server.

With Tomcat, you can set up the sandbox so that you can create the
local directory too. You could login, fill in the blanks on a web
page, hit submit, and be done.

An HTTPS solution also has the advantage that most corporate firewalls
already allow that to pass. Some places won't allow anything to
penetrate the firewall except HTTP and HTTPS (ports 80 and 443).

That is beyond the scope of this list. But if you contact me off-list
at rnf@... I can give you a hand with either solution.


Rick

--- In Firebird-Java@yahoogroups.com, David Jencks <david_jencks@y...>
wrote:
>
> 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)
> >
> >
> >
> >