Hi Elke,
Thanks for the reply. I am puzzled as to why I do not see any locks show
up in the System LOCKS table.
Here's what I am doing:
- the app starts up, and I create a pool of 25 connections to the database
- a user tries to add a form
- this involves more than just adding it to the database, so the FORMS
and FORMSCATEGORIES tables need to be locked while this process takes place
- I therefore grab a connection from the pool, execute a COMMIT
statement, followed by:
"LOCK (WAIT) TABLE forms IN EXCLUSIVE MODE"
- I have put a pause in the program at that point so I can check things,
but when I select * from LOCKS, I get nothing.
I am using the JDBC driver, and believe it defaults to auto-commit ON.
Please help! Can you point me in the right direction? How can I check/set
the REQUEST_TIMEOUT parameter?
Many thanks,
David
"Zabach, Elke" <[EMAIL PROTECTED]> on 13/05/2003 02:28:08 AM
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>,
[EMAIL PROTECTED]
cc:
Subject: RE: Locking question
[EMAIL PROTECTED] wrote:
>
> Hi Elke,
>
> Thanks for the reply.
>
> If I have a set of 25 pooled connections, which are created
> when I startup,
> when does a transaction start?
>
> In my code, I grab one of the connections, perform an execute
> on it, and
> then release it back into the pool. From the docs, I could
> only see that a
> transaction begins when I create a connection over JDBC using
>
> Connection connection = DriverManager.getConnection
> ("jdbc:sapdb://localhost/kiosk", "kiosk", "kiosk");
>
> If I only create these connections once, and never close
> them, can I still
> start/end transactions that lock/unlock tables?
>
transactions are started if a database-session in the kernel is started,
i.e. when you create that connection over whatever client you want.
And a new transaction is started always after commit/rollback of the old
one.
--> commit/rollback will release locks, close the old transaction, open a
new one.
If you are not just performing queries, but insert/update/delete or
ddl-commands,
it is NECESSARY to commit your transaction, otherwise an explicit or
implicit
rollback of another guy using that connection of your pool will rollback
YOUR
insert/update/delete or ddl as well.
Did you check of the autocommit-option may be good for your application?
And please check, if you can close cursor if they are not needed any more,
otherwise they may remain too long and need space in the db much more
needed
by other things. AFAIK JDBC has something to help you with.
Elke
SAP Labs Berlin
>
>
> "Zabach, Elke" <[EMAIL PROTECTED]> on 12/05/2003 04:58:04 AM
>
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED]
> cc:
> Subject: RE: Locking question
>
>
> [EMAIL PROTECTED]
> >
> > I am trying to get my head around locking.
> >
> > If I create an exclusive lock on a table, to do an insert and
> > some other
> > stuff, am I stopping someone reading from it too?
>
> YES
>
>
> > If so, and
> > they try a
> > read and it is locked, what happens? Does it just wait until
> > the lock is
> > released?
>
> It waits until lock is released or until time given by configuration
> parameter REQUEST_TIMEOUT is over (who comes first).
>
>
> >
> > I am using JDBC and have a pool of connections which are all
> > created at
> > startup. In this scenerio, how do I release a lock on a
> > table that I have
> > created using LOCK...?
>
> Locks are released by ending the transaction using ROLLBACK or COMMIT
>
> Elke
> SAP Labs Berlin
>
>
>
>
>
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general