You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Jayaram Subramanian <rs...@gmail.com> on 2010/01/31 05:35:03 UTC
Switching across connections
Hi,
When we have 2 connections open to a db, how can we switch between
connections and make the connection we require as active connection. I am
trying to convert the following segment to JUnit. Is there any equivalent
method of set connection described below?
With Regards
Jayaram
connect 'wombat' as conn1;
create table t1 (c11 int generated always as identity (start with 101,
increment by 3), c12 int);
create table t2 (c21 int generated always as identity (start with 201,
increment by 5), c22 int);
-- IDENTITY_VAL_LOCAL() will return NULL because no single row insert into
table with identity column yet on this connection conn1
values IDENTITY_VAL_LOCAL();
commit;
-- connection two
connect 'wombat' as conn2;
-- IDENTITY_VAL_LOCAL() will return NULL because no single row insert into
table with identity column yet on this connection conn2
values IDENTITY_VAL_LOCAL();
insert into t2 (c22) values (1);
-- IDENTITY_VAL_LOCAL() will return 201 because there was single row insert
into table t2 with identity column on this connection conn2
values IDENTITY_VAL_LOCAL();
set connection conn1;
-- IDENTITY_VAL_LOCAL() will continue to return NULL because no single row
insert into table with identity column yet on this connection conn1
Re: Switching across connections
Posted by Bryan Pendleton <bp...@amberpoint.com>.
> When we have 2 connections open to a db, how can we switch between
> connections and make the connection we require as active connection. I
> am trying to convert the following segment to JUnit. Is there any
> equivalent method of set connection described below?
Hi Jayaram,
Have a look at GrantRevokeDDLTest.java, which has a number of examples
of JUnit test cases which switch back and forth between connections.
thanks,
bryan