You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Kostas Karadamoglou <ka...@yahoo.gr> on 2005/08/22 02:26:52 UTC

Simple question about Derby and Transactions

Hello,

I am new to Derby and to Transactions in general.

I want to perform some tasks to my databases using one thread and lock 
the table that it uses from the remaining threads.


My qyestion is simple!

Haw can this be done with Jdbc and Derby?

I dont care about distributed transaction.

Thank you in advance, Kostas


Re: Simple question about Derby and Transactions

Posted by Kostas Karadamoglou <ka...@yahoo.gr>.
Thank you very much for the hint!


Oyvind.Bakksjo@Sun.COM wrote:
> Kostas Karadamoglou wrote:
> 
>> Can I set the isolation level using JDBC?
> 
> 
> Yes.
> 
>> How can I do it?
> 
> 
> Connection.setTransactionIsolation()
> 
> See http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html
> 


Re: Simple question about Derby and Transactions

Posted by Oy...@Sun.COM.
Kostas Karadamoglou wrote:
> Can I set the isolation level using JDBC?

Yes.

> How can I do it?

Connection.setTransactionIsolation()

See http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html

-- 
Øyvind Bakksjø
Sun Microsystems, Database Technology Group
Haakon VII gt. 7b, N-7485 Trondheim, Norway
Tel: x43419 / +47 73842119, Fax: +47 73842101

Re: Simple question about Derby and Transactions

Posted by Kostas Karadamoglou <ka...@yahoo.gr>.
Can I set the isolation level using JDBC?

How can I do it?

Oyvind.Bakksjo@Sun.COM wrote:
> Kostas Karadamoglou wrote:
> 
>> Hello,
>>
>> I am new to Derby and to Transactions in general.
>>
>> I want to perform some tasks to my databases using one thread and lock 
>> the table that it uses from the remaining threads.
> 
> 
> You may achieve what you want by proper usage of transaction isolation 
> levels, instead of explicitly locking an entire table. This, of course, 
> depends on what your application is trying to do. Anyway, if you are 
> planning to read some literature on transactions, "isolation levels" 
> should be on your menu.
> 


Re: Simple question about Derby and Transactions

Posted by Oy...@Sun.COM.
Kostas Karadamoglou wrote:
> Hello,
> 
> I am new to Derby and to Transactions in general.
> 
> I want to perform some tasks to my databases using one thread and lock 
> the table that it uses from the remaining threads.

You may achieve what you want by proper usage of transaction isolation 
levels, instead of explicitly locking an entire table. This, of course, 
depends on what your application is trying to do. Anyway, if you are 
planning to read some literature on transactions, "isolation levels" 
should be on your menu.

-- 
Øyvind Bakksjø
Sun Microsystems, Database Technology Group
Haakon VII gt. 7b, N-7485 Trondheim, Norway
Tel: x43419 / +47 73842119, Fax: +47 73842101

Re: Simple question about Derby and Transactions

Posted by Øystein Grøvlen <Oy...@Sun.COM>.
>>>>> "KK" == Kostas Karadamoglou <ka...@yahoo.gr> writes:

    KK> Hello,
    KK> I am new to Derby and to Transactions in general.

    KK> I want to perform some tasks to my databases using one thread and lock
    KK> the table that it uses from the remaining threads.



    KK> My qyestion is simple!

    KK> Haw can this be done with Jdbc and Derby?

I think you need to consult a JDBC text book and the Derby manuals in
order to learn JDBC.  You could also learn something from the example
programs that comes with Derby.

In order to lock a table for the rest of a transaction you can execute
the SQL statement: LOCK TABLE t IN EXCLUSIVE MODE;

-- 
Øystein