geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sara T <sara.tas...@insiel.it>
Subject Re: How can I set ExceptionSorterClass property for my database pool?
Date Wed, 30 Apr 2008 09:52:59 GMT



djencks wrote:
> 
> 
> On Apr 29, 2008, at 3:38 AM, Sara T wrote:
> 
>>
>>
>> Thank you very much for your answer.
>>
>> I've got another question, to understand how exception transaction
>> management works: why does ra.xml set ExceptionSorterClass property as
>> org.tranql.connector.AllExceptionsAreFatalSorter by default in
>> tranql-connector-ra-1.3.rar?
>>
>> This is my situation: my database is Oracle Thin type, so if I  
>> deploy it
>> using Geronimo console, TranQL Generic JDBC Resource Adapter is used  
>> for the
>> pool.
> 
> I'm not exactly an oracle expert.  Is there some reason you don't use  
> the oracle specific tranql wrapper?
> 
> 

If I choose "Oracle Thin" as Database Type in the Geronimo database pool
wizard, TranQL Generic JDBC Resource Adapter is automatically used




> 
>>
>> There’s a problem with my application when, for exemple, there are two
>> update instructions in one transaction and the second one catches an
>> SQLException (ex: invalid sql).
>> In this case the second update isn’t committed, but the first one is.
>> I think (but it’s true?) that is because connectionError method in
>> org.tranql.connector.AbstractManagedConnection checks if  
>> exceptionSorter is
>> fatal.
>> In this case connection is returned and cleanup method in
>> org.tranql.connector.jdbc.ManagedJDBCConnection class is called: in  
>> this
>> method  physical connection is committed  (setAutoCommit(true)).
>> Otherwise (if exceptionSorter isn’t fatal) I could catch it in my
>> application and call rollback for the connection before that clean  
>> method is
>> called.
>>
> 
> This doesn't sound right.  You should still get transactional  
> behavior, i.e. neither update should be committed if you are really in  
> a transaction and the second update causes an exception.  The behavior  
> you describe should only happen if there is no jta transaction  
> containing both updates.  How are transactions controlled in your app?
> 
>> Do you think that this could be my case?
>> Is it right to set ExceptionSorterClass property as
>> org.tranql.connector.NoExceptionsAreFatalSorter  to call rollback  
>> from my
>> application in exception case (and so deploy my database manually
>> using a deployment plan, as you said in your previous answer) ?
> 
> This should work for your situation.  The problem is that if a real  
> fatal connection error occurs (such as the tcp connection to the  
> database going down) the connector framework will not be able to clean  
> up the connections and you will have to wait for them to all time out.
>>
>> Is there any way to do it using Geronimo console?
> 
> I don't see a way to set the sorter using the console.  I'm not sure  
> why this is left out.
> 
> I'm most concerned about the commit of the first update when the  
> second throws an exception.
> 
> 


I’ve got an old client-server application. I want to migrate it from oc4j to
Geronimo. It uses a stateful EJB to manage client calls to the database and
each call is made into a UserTransaction.

In case of transaction with two updates and the second update causes
SQLException, these are the main steps:

- in my ejb: begin userTransacion
- first executeUpdate – no exception
- second executeUpdate – SQLException
- org.tranql.connector.jdbc.PreparedStatementHandle.executeUpdate catches
the exception

- org.tranql.connector.AbstractManagedConnection.connectionError checks if
the exception is fatal.

If the exception is not fatal it throws the exception and the control comes
back to my application, which executes the rollback and the connection is
closed 

- in my ejb: rollback of the userTransacion

- org.tranql.connector.jdbc.ManagedJDBCConnection.cleanup


If the exception is fatal some of the methods called are:

- org.tranql.connector.AbstractManagedConnection.unfilteredConnectionError
- org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.
returnConnection

- org.tranql.connector.jdbc.ManagedJDBCConnection.cleanup, which is:

  public void cleanup() throws ResourceException {
        super.cleanup();
        Connection c = (Connection) physicalConnection;
        try {
            //TODO reset tx isolation level
            if (!c.getAutoCommit()) {
                c.setAutoCommit(true);
            }
        } catch (SQLException e) {
            throw new ResourceException("Could not reset autocommit when
returning to pool", e);
        }
    }


I think that setAutoCommit(true) commits the first update.
Is this behaviour caused by the use of Stateful EJB?

Thanks 

Sara




> 
> thanks
> david jencks
> 
>>
>>
>>
>> Thanks for your time!
>>
>> Sara
>>
>>
>>
>>
>> djencks wrote:
>>>
>>>
>>> On Apr 23, 2008, at 7:43 AM, Sara T wrote:
>>>
>>>>
>>>> Hi all,
>>>>
>>>> I’m new with Geronimo and I need your help to configure my database
>>>> pool.
>>>> In particular I’ve seen that if deploy database pool through the
>>>> Geronimo
>>>> console, by default ExceptionSorterClass property is set as
>>>> org.tranql.connector.AllExceptionsAreFatalSorter: I need to change
>>>> it in
>>>> org.tranql.connector.NoExceptionsAreFatalSorter.
>>>>
>>>> Which is the best way to do that?
>>>
>>> The very best way to do this is to write a database-specific wrapper,
>>> such as tranql has for derby, db2, postgres, mysql, and oracle.  Many
>>> databases have XADatasources or PooledDataSources that already notify
>>> the environment in case of a fatal connection error, and using one of
>>> these avoids the obvious problems with both provided exception  
>>> sorters.
>>>
>>>> Should I change it in
>>>> tranql-connector-ra-1.3.rar\META-INF\ra.xml file and then use  
>>>> Geronimo
>>>> database pool wizard or create my plan and deploy the pool via the
>>>> command-line deploy tool?
>>>> In this second case what happens if, after the deploy, I change  
>>>> other
>>>> properties using the Geronimo console? ExceptionSorterClass property
>>>> can be
>>>> overwritten with the default value? (I don’t know where pool
>>>> properties are
>>>> saved).
>>>
>>> You should set the class in your geronimo plan. After deployment the
>>> new value will not be overwritten by changes you make though the
>>> console.
>>>
>>> Let us know if you have further problems
>>> thanks
>>> david jencks
>>>
>>>>
>>>>
>>>> Thanks and sorry for my english!
>>>>
>>>> Sara
>>>>
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/How-can-I-set-ExceptionSorterClass-property-for-my-database-pool--tp16834635s134p16834635.html
>>>> Sent from the Apache Geronimo - Users mailing list archive at
>>>> Nabble.com.
>>>>
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/How-can-I-set-ExceptionSorterClass-property-for-my-database-pool--tp16834635s134p16957612.html
>> Sent from the Apache Geronimo - Users mailing list archive at  
>> Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-can-I-set-ExceptionSorterClass-property-for-my-database-pool--tp16834635s134p16979231.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message