Subject Re: [IB-Java] JDBC Type 4 Driver Status and final build for testing
Author David Jencks
I think you'll be the first;-)

I'm not very familiar with what is present in a servlet environment. Do
you have jndi? If so, you should be able to do something roughly like this:

ManagedConnectionFactory mcf = new FBManagedConnectionFactory();
//set the properties like which db, if you want usename and password
mcf.setDatabase("localhost:/path/to/db.gdb");
FBConnectionRequestInfo cri = new FBConnectionRequestInfo();
cri.setUser("sysdba");
cri.setPassword("masterkey");
mcf.setConnectionRequestInfo(cri);
DataSource ds = mcf.createConnectionFactory();

/*Now you have a Datasource that will give you connections to the specified
database using the user and password you specified. Unfortuneately, the
connections aren't pooled - you'd need to call
mcf.createConnectionFactory(ARealPoolingConnectionManager).
*/
//bind into jndi

new InitialContext().bind("java:/myDS", ds);

In your servlet,

DataSource ds = (DataSource)(new InitialContext().lookup("java:/myDS"));
Connection c = ds.getConnection();


This is off the top of my head, untested in any way.

I'm not sure of the autocommit status of connections obtained this way.
I'm pretty sure Autocommit = false.

If you do
FBConnection fbc = (FBConnection)c;
LocalTransaction lt = fbc.getLocalTransaction();

you can use this to control transaction boundaries. I'm not sure commit
and rollback are implmented in the connection itself.

lt.begin();
(do work)
lt.commit();

Let us know if and how it works.

David Jencks

On 2001.10.25 23:22:16 -0400 jwcanada@... wrote:
> I took a look the type4 driver and it seems quite nicer than the
> Borland Interclient. Just download the source and built it successful
> in Win2K. I am trying to find one sample example to use the driver in
> a java servlet.
>
> Any help would be appreciated.
>
> jw
>
>
>
>
>
>
>
>
> To unsubscribe from this group, send an email to:
> IB-Java-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>