|
From: Levkovitch, L. <lle...@ac...> - 2004-05-12 18:02:37
|
Folks,
I am using a datasource to have my Spring DAOs connect to Oracle database.
Apparently, with my set up, autocommit is turned on, and this is not what I
need!
I have actually put this line of code inside one of the DAOs'
afterPropertiesSet() method:
logger.debug("autocommit is " + getDs().getConnection().getAutoCommit());
and this prints "autocommit is true".
Is there a way to configure my datasource so that autocommit is set to
false? I am using JBoss 3.2.1 with Oracle 9.2. In one of JBoss forums it
actually.
The datasource is defined in myapp-ds.xml file like this:
(this is based on the example that came with JBoss)
<datasources>
<local-tx-datasource>
<jndi-name>myapp-ds</jndi-name>
<connection-url>jdbc:oracle:thin:@[my database
name]</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>[my user name]</user-name>
<password>[my password]</password>
<min-pool-size>3</min-pool-size>
<max-pool-size>30</max-pool-size>
<blocking-timeout-millis>3000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleEx
ceptionSorter</exception-sorter-class-name>
</local-tx-datasource>
</datasources>
All my DAO objects use the dataSource bean which is defined in my
application context as follows:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"
singleton="true" lazy-init="default" autowire="default"
dependency-check="default">
- <property name="jndiName">
<value>myapp-ds</value>
</property>
- <property name="resourceRef">
<value>true</value>
</property>
</bean>
Thank you very much!
Lidia
|
|
From: Levkovitch, L. <lle...@ac...> - 2004-05-12 22:09:23
|
I think I've sent this to a wrong list before... Sorry!
=========================
Thanks to Rod and Colin for responses and advice, and big thanks to Dmitriy
for on-site debugging!
My problem was actually in my own code. Because I am using some special
features of Oracle 9 (namely, XMLType), I have to get a connection and
create my own prepared statements with it. I was getting this connection
from my DAO's datasource (getDs().getConnection()), instead of using
DataSourceUtils.getConnection(getDs()) as the documentation instructs. As
soon as I changed that, all my transactions started to work perfectly!
Now I understand that I don't really have to change the autocommit property,
but in case someone is interested, here is what I found out (and it isn't
much!). According to JBoss forums, autocommit is SUPPOSED to be off with my
configuration (which is really just the default Oracle config file for
JBoss).
Oracle's instructions for creating a datasource file do not discuss
autocommit at all, and it seems that there's no property in the datasource
configuration that controls it; one can only change it programmatically.
I guess in my case it is off by default, but then something switches it on
as JBoss starts up with whatever services I have set up there. Not that it
bothers me now, since Spring takes care of everything.
Once again - thanks, everyone!
Lidia
-----Original Message-----
Folks,
I am using a datasource to have my Spring DAOs connect to Oracle database.
Apparently, with my set up, autocommit is turned on, and this is not what I
need! I have actually put this line of code inside one of the DAOs'
afterPropertiesSet() method:
logger.debug("autocommit is " + getDs().getConnection().getAutoCommit());
and this prints "autocommit is true".
Is there a way to configure my datasource so that autocommit is set to
false? I am using JBoss 3.2.1 with Oracle 9.2. In one of JBoss forums it
actually.
The datasource is defined in myapp-ds.xml file like this:
(this is based on the example that came with JBoss) <datasources>
<local-tx-datasource>
<jndi-name>myapp-ds</jndi-name>
<connection-url>jdbc:oracle:thin:@[my database
name]</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>[my user name]</user-name>
<password>[my password]</password>
<min-pool-size>3</min-pool-size>
<max-pool-size>30</max-pool-size>
<blocking-timeout-millis>3000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleEx
ceptionSorter</exception-sorter-class-name>
</local-tx-datasource>
</datasources>
All my DAO objects use the dataSource bean which is defined in my
application context as follows: <bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean"
singleton="true" lazy-init="default" autowire="default"
dependency-check="default">
- <property name="jndiName">
<value>myapp-ds</value>
</property>
- <property name="resourceRef">
<value>true</value>
</property>
</bean>
Thank you very much!
Lidia
|
|
From: Dmitriy K. <dko...@ru...> - 2004-05-12 22:20:18
|
BTW, is there a possibility to create an abstraction for Oracle XMLType
so the application code wouldn't have to deal with the low level JDBC
code? Kinda like LOB support.
Thomas, Juergen?
Regards,
Dmitriy.
Levkovitch, Lidia wrote:
>I think I've sent this to a wrong list before... Sorry!
>=========================
>Thanks to Rod and Colin for responses and advice, and big thanks to Dmitriy
>for on-site debugging!
>
>My problem was actually in my own code. Because I am using some special
>features of Oracle 9 (namely, XMLType), I have to get a connection and
>create my own prepared statements with it. I was getting this connection
>from my DAO's datasource (getDs().getConnection()), instead of using
>DataSourceUtils.getConnection(getDs()) as the documentation instructs. As
>soon as I changed that, all my transactions started to work perfectly!
>
>Now I understand that I don't really have to change the autocommit property,
>but in case someone is interested, here is what I found out (and it isn't
>much!). According to JBoss forums, autocommit is SUPPOSED to be off with my
>configuration (which is really just the default Oracle config file for
>JBoss).
>Oracle's instructions for creating a datasource file do not discuss
>autocommit at all, and it seems that there's no property in the datasource
>configuration that controls it; one can only change it programmatically.
>I guess in my case it is off by default, but then something switches it on
>as JBoss starts up with whatever services I have set up there. Not that it
>bothers me now, since Spring takes care of everything.
>
>Once again - thanks, everyone!
>Lidia
>
>-----Original Message-----
>Folks,
>
>I am using a datasource to have my Spring DAOs connect to Oracle database.
>Apparently, with my set up, autocommit is turned on, and this is not what I
>need! I have actually put this line of code inside one of the DAOs'
>afterPropertiesSet() method:
>logger.debug("autocommit is " + getDs().getConnection().getAutoCommit());
>and this prints "autocommit is true".
>
>Is there a way to configure my datasource so that autocommit is set to
>false? I am using JBoss 3.2.1 with Oracle 9.2. In one of JBoss forums it
>actually.
>
>The datasource is defined in myapp-ds.xml file like this:
>(this is based on the example that came with JBoss) <datasources>
> <local-tx-datasource>
> <jndi-name>myapp-ds</jndi-name>
>
> <connection-url>jdbc:oracle:thin:@[my database
>name]</connection-url>
> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
> <user-name>[my user name]</user-name>
> <password>[my password]</password>
> <min-pool-size>3</min-pool-size>
> <max-pool-size>30</max-pool-size>
> <blocking-timeout-millis>3000</blocking-timeout-millis>
> <idle-timeout-minutes>15</idle-timeout-minutes>
>
><exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleEx
>ceptionSorter</exception-sorter-class-name>
> </local-tx-datasource>
></datasources>
>
>All my DAO objects use the dataSource bean which is defined in my
>application context as follows: <bean id="dataSource"
>class="org.springframework.jndi.JndiObjectFactoryBean"
>singleton="true" lazy-init="default" autowire="default"
>dependency-check="default">
>- <property name="jndiName">
> <value>myapp-ds</value>
> </property>
>- <property name="resourceRef">
> <value>true</value>
> </property>
> </bean>
>
>Thank you very much!
>Lidia
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by Sleepycat Software
>Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
>deliver higher performing products faster, at low TCO.
>http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
|
|
From: Rod J. <rod...@in...> - 2004-05-12 22:51:18
|
Would be cool but when I last looked at it over a year ago it was scary
stuff. If anyone can do it, we can. Might be good to see how many people
want it... I would probably use it from time to time. Not too often though.
----- Original Message -----
From: "Dmitriy Kopylenko" <dko...@ru...>
To: <spr...@li...>
Sent: Thursday, May 13, 2004 12:19 AM
Subject: Re: [Springframework-developer] Turning off autocommit in JBoss /
Oracle datasource
> BTW, is there a possibility to create an abstraction for Oracle XMLType
> so the application code wouldn't have to deal with the low level JDBC
> code? Kinda like LOB support.
>
> Thomas, Juergen?
>
> Regards,
> Dmitriy.
>
>
> Levkovitch, Lidia wrote:
>
> >I think I've sent this to a wrong list before... Sorry!
> >=========================
> >Thanks to Rod and Colin for responses and advice, and big thanks to
Dmitriy
> >for on-site debugging!
> >
> >My problem was actually in my own code. Because I am using some special
> >features of Oracle 9 (namely, XMLType), I have to get a connection and
> >create my own prepared statements with it. I was getting this connection
> >from my DAO's datasource (getDs().getConnection()), instead of using
> >DataSourceUtils.getConnection(getDs()) as the documentation instructs. As
> >soon as I changed that, all my transactions started to work perfectly!
> >
> >Now I understand that I don't really have to change the autocommit
property,
> >but in case someone is interested, here is what I found out (and it isn't
> >much!). According to JBoss forums, autocommit is SUPPOSED to be off with
my
> >configuration (which is really just the default Oracle config file for
> >JBoss).
> >Oracle's instructions for creating a datasource file do not discuss
> >autocommit at all, and it seems that there's no property in the
datasource
> >configuration that controls it; one can only change it programmatically.
> >I guess in my case it is off by default, but then something switches it
on
> >as JBoss starts up with whatever services I have set up there. Not that
it
> >bothers me now, since Spring takes care of everything.
> >
> >Once again - thanks, everyone!
> >Lidia
> >
> >-----Original Message-----
> >Folks,
> >
> >I am using a datasource to have my Spring DAOs connect to Oracle
database.
> >Apparently, with my set up, autocommit is turned on, and this is not what
I
> >need! I have actually put this line of code inside one of the DAOs'
> >afterPropertiesSet() method:
> >logger.debug("autocommit is " + getDs().getConnection().getAutoCommit());
> >and this prints "autocommit is true".
> >
> >Is there a way to configure my datasource so that autocommit is set to
> >false? I am using JBoss 3.2.1 with Oracle 9.2. In one of JBoss forums it
> >actually.
> >
> >The datasource is defined in myapp-ds.xml file like this:
> >(this is based on the example that came with JBoss) <datasources>
> > <local-tx-datasource>
> > <jndi-name>myapp-ds</jndi-name>
> >
> > <connection-url>jdbc:oracle:thin:@[my database
> >name]</connection-url>
> > <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
> > <user-name>[my user name]</user-name>
> > <password>[my password]</password>
> > <min-pool-size>3</min-pool-size>
> > <max-pool-size>30</max-pool-size>
> > <blocking-timeout-millis>3000</blocking-timeout-millis>
> > <idle-timeout-minutes>15</idle-timeout-minutes>
> >
>
><exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleE
x
> >ceptionSorter</exception-sorter-class-name>
> > </local-tx-datasource>
> ></datasources>
> >
> >All my DAO objects use the dataSource bean which is defined in my
> >application context as follows: <bean id="dataSource"
> >class="org.springframework.jndi.JndiObjectFactoryBean"
> >singleton="true" lazy-init="default" autowire="default"
> >dependency-check="default">
> >- <property name="jndiName">
> > <value>myapp-ds</value>
> > </property>
> >- <property name="resourceRef">
> > <value>true</value>
> > </property>
> > </bean>
> >
> >Thank you very much!
> >Lidia
> >
> >
> >-------------------------------------------------------
> >This SF.Net email is sponsored by Sleepycat Software
> >Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
> >deliver higher performing products faster, at low TCO.
> >http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
> >_______________________________________________
> >Springframework-developer mailing list
> >Spr...@li...
> >https://lists.sourceforge.net/lists/listinfo/springframework-developer
> >
> >
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Sleepycat Software
> Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
> deliver higher performing products faster, at low TCO.
> http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: Rod J. <rod...@in...> - 2004-05-12 19:10:27
|
Lidia
You're right. Autocommit is evil in non-trivial apps. However, this is
really a JBoss question. Have you checked their lists/forums/FAQs?
Regards
Rod
----- Original Message -----
From: "Levkovitch, Lidia" <lle...@su...>
To: <spr...@li...>
Sent: Wednesday, May 12, 2004 7:02 PM
Subject: [Springframework-developer] Turning off autocommit in JBoss /
Oracle datasource
> Folks,
>
> I am using a datasource to have my Spring DAOs connect to Oracle database.
> Apparently, with my set up, autocommit is turned on, and this is not what
I
> need!
> I have actually put this line of code inside one of the DAOs'
> afterPropertiesSet() method:
> logger.debug("autocommit is " + getDs().getConnection().getAutoCommit());
> and this prints "autocommit is true".
>
> Is there a way to configure my datasource so that autocommit is set to
> false? I am using JBoss 3.2.1 with Oracle 9.2. In one of JBoss forums it
> actually.
>
> The datasource is defined in myapp-ds.xml file like this:
> (this is based on the example that came with JBoss)
> <datasources>
> <local-tx-datasource>
> <jndi-name>myapp-ds</jndi-name>
>
> <connection-url>jdbc:oracle:thin:@[my database
> name]</connection-url>
> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
> <user-name>[my user name]</user-name>
> <password>[my password]</password>
> <min-pool-size>3</min-pool-size>
> <max-pool-size>30</max-pool-size>
> <blocking-timeout-millis>3000</blocking-timeout-millis>
> <idle-timeout-minutes>15</idle-timeout-minutes>
>
>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleEx
> ceptionSorter</exception-sorter-class-name>
> </local-tx-datasource>
> </datasources>
>
> All my DAO objects use the dataSource bean which is defined in my
> application context as follows:
> <bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean"
> singleton="true" lazy-init="default" autowire="default"
> dependency-check="default">
> - <property name="jndiName">
> <value>myapp-ds</value>
> </property>
> - <property name="resourceRef">
> <value>true</value>
> </property>
> </bean>
>
> Thank you very much!
> Lidia
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Sleepycat Software
> Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
> deliver higher performing products faster, at low TCO.
> http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: Colin S. <col...@ex...> - 2004-05-12 19:29:16
|
Actually I think this is just bad usage/config of Spring.
A connection returned from a DataSource is normally set to
autocommit=true as per the Connection JavaDocs.
Now our TransactionManagers (like DataSourceTransactionManager) do set
autocommit to false when starting a transaction, and restore it back to
whatever it was afterwards.
My feeling Lidia is that you are not properly wrapping your DAO/Mapper
objects in either Spring declarative or programmatic transactions, so in
your test code you are not actually getting a connection while in a
transaciton. How to do transactional wrapping is described in a fair
amount of detail in the Spring manual. If you have any need for more
info after looking at that, or think that the problem is something else,
please post another message with more info.
Regards,
Colin
Rod Johnson wrote:
>Lidia
>
>You're right. Autocommit is evil in non-trivial apps. However, this is
>really a JBoss question. Have you checked their lists/forums/FAQs?
>
>Regards
>Rod
>
>----- Original Message -----
>From: "Levkovitch, Lidia" <lle...@su...>
>To: <spr...@li...>
>Sent: Wednesday, May 12, 2004 7:02 PM
>Subject: [Springframework-developer] Turning off autocommit in JBoss /
>Oracle datasource
>
>
>
>
>>Folks,
>>
>>I am using a datasource to have my Spring DAOs connect to Oracle database.
>>Apparently, with my set up, autocommit is turned on, and this is not what
>>
>>
>I
>
>
>>need!
>>I have actually put this line of code inside one of the DAOs'
>>afterPropertiesSet() method:
>>logger.debug("autocommit is " + getDs().getConnection().getAutoCommit());
>>and this prints "autocommit is true".
>>
>>Is there a way to configure my datasource so that autocommit is set to
>>false? I am using JBoss 3.2.1 with Oracle 9.2. In one of JBoss forums it
>>actually.
>>
>>The datasource is defined in myapp-ds.xml file like this:
>>(this is based on the example that came with JBoss)
>><datasources>
>> <local-tx-datasource>
>> <jndi-name>myapp-ds</jndi-name>
>>
>><connection-url>jdbc:oracle:thin:@[my database
>>name]</connection-url>
>> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
>> <user-name>[my user name]</user-name>
>> <password>[my password]</password>
>> <min-pool-size>3</min-pool-size>
>> <max-pool-size>30</max-pool-size>
>> <blocking-timeout-millis>3000</blocking-timeout-millis>
>> <idle-timeout-minutes>15</idle-timeout-minutes>
>>
>>
>>
>>
><exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleEx
>
>
>>ceptionSorter</exception-sorter-class-name>
>> </local-tx-datasource>
>></datasources>
>>
>>All my DAO objects use the dataSource bean which is defined in my
>>application context as follows:
>><bean id="dataSource"
>>
>>
>class="org.springframework.jndi.JndiObjectFactoryBean"
>
>
>>singleton="true" lazy-init="default" autowire="default"
>>dependency-check="default">
>>- <property name="jndiName">
>> <value>myapp-ds</value>
>> </property>
>>- <property name="resourceRef">
>> <value>true</value>
>> </property>
>> </bean>
>>
>>Thank you very much!
>>Lidia
>>
>>
|
|
From: Dmitriy K. <dko...@ru...> - 2004-05-12 19:37:48
|
Colin,
I'm working with Lidia on that one. I'm so curious what the hell is going on... The log actually says that the TxManager initiating rollback (when unchecked exception is
thrown from the service method), but the actual data is committed... We'll let you know.
Regards,
Dmitriy.
Colin Sampaleanu wrote:
> Actually I think this is just bad usage/config of Spring.
>
> A connection returned from a DataSource is normally set to
> autocommit=true as per the Connection JavaDocs.
>
> Now our TransactionManagers (like DataSourceTransactionManager) do set
> autocommit to false when starting a transaction, and restore it back to
> whatever it was afterwards.
>
> My feeling Lidia is that you are not properly wrapping your DAO/Mapper
> objects in either Spring declarative or programmatic transactions, so in
> your test code you are not actually getting a connection while in a
> transaciton. How to do transactional wrapping is described in a fair
> amount of detail in the Spring manual. If you have any need for more
> info after looking at that, or think that the problem is something else,
> please post another message with more info.
>
> Regards,
> Colin
>
> Rod Johnson wrote:
>
>> Lidia
>>
>> You're right. Autocommit is evil in non-trivial apps. However, this is
>> really a JBoss question. Have you checked their lists/forums/FAQs?
>>
>> Regards
>> Rod
>>
>> ----- Original Message -----
>> From: "Levkovitch, Lidia" <lle...@su...>
>> To: <spr...@li...>
>> Sent: Wednesday, May 12, 2004 7:02 PM
>> Subject: [Springframework-developer] Turning off autocommit in JBoss /
>> Oracle datasource
>>
>>
>>
>>
>>> Folks,
>>>
>>> I am using a datasource to have my Spring DAOs connect to Oracle
>>> database.
>>> Apparently, with my set up, autocommit is turned on, and this is not
>>> what
>>>
>>
>> I
>>
>>
>>> need!
>>> I have actually put this line of code inside one of the DAOs'
>>> afterPropertiesSet() method:
>>> logger.debug("autocommit is " +
>>> getDs().getConnection().getAutoCommit());
>>> and this prints "autocommit is true".
>>>
>>> Is there a way to configure my datasource so that autocommit is set to
>>> false? I am using JBoss 3.2.1 with Oracle 9.2. In one of JBoss forums it
>>> actually.
>>>
>>> The datasource is defined in myapp-ds.xml file like this:
>>> (this is based on the example that came with JBoss)
>>> <datasources>
>>> <local-tx-datasource>
>>> <jndi-name>myapp-ds</jndi-name>
>>>
>>> <connection-url>jdbc:oracle:thin:@[my database
>>> name]</connection-url>
>>> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
>>> <user-name>[my user name]</user-name>
>>> <password>[my password]</password>
>>> <min-pool-size>3</min-pool-size>
>>> <max-pool-size>30</max-pool-size>
>>> <blocking-timeout-millis>3000</blocking-timeout-millis>
>>> <idle-timeout-minutes>15</idle-timeout-minutes>
>>>
>>>
>>>
>>
>> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleEx
>>
>>
>>
>>> ceptionSorter</exception-sorter-class-name>
>>> </local-tx-datasource>
>>> </datasources>
>>>
>>> All my DAO objects use the dataSource bean which is defined in my
>>> application context as follows:
>>> <bean id="dataSource"
>>>
>>
>> class="org.springframework.jndi.JndiObjectFactoryBean"
>>
>>
>>> singleton="true" lazy-init="default" autowire="default"
>>> dependency-check="default">
>>> - <property name="jndiName">
>>> <value>myapp-ds</value>
>>> </property>
>>> - <property name="resourceRef">
>>> <value>true</value>
>>> </property>
>>> </bean>
>>>
>>> Thank you very much!
>>> Lidia
>>>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Sleepycat Software
> Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
> deliver higher performing products faster, at low TCO.
> http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
|