ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brandon Goodin" <brandon.goo...@gmail.com>
Subject Re: autoCommit=false, but still commits?
Date Tue, 28 Aug 2007 13:18:56 GMT
Since Tomcat is managing your datasource and connection pool try setting
your autoCommit in Tomcat.

P.S. you emailed me personally... i took the liberty of putting it back on
the list

Brandon
On 8/28/07, Leffingwell, Jonathan R CTR FRCSE, JAX 7.2.2 <
jonathan.leffingwell.ctr@navy.mil> wrote:
>
>  We use a database.properties file, which looks like this:
>
> [begin database.properties]
> ####################################
> # Database Connectivity Properties
> ####################################
>
> default=serverds
> driver=oracle.jdbc.driver.OracleDriver
>
> #################################################
>
> #serverds:
> serverds.type=JNDI
> serverds.datasource=java:comp/env/jdbc/taaDataSource
> serverds.url=
> serverds.username=
> serverds.password=
> [end database.properties]
>
>
> The Tomcat server.xml file looks like this:
>
> [begin server.xml]
> <!-- Global JNDI resources -->
>   <GlobalNamingResources>
>
>     <!-- Test entry for demonstration purposes -->
>     <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
>
>     <!-- Help pages  -->
>     <Environment name="help-tag-connector" type="java.lang.String"
> value="help/DMAPS_Help.htm"/>
>
>     <!-- Editable user database that can also be used by UserDatabaseRealm
> to authenticate users -->
>     <Resource auth="Container" description="User database that can be
> updated and saved" name="UserDatabase" type="
> org.apache.catalina.UserDatabase">
>
>     </Resource>
>     <ResourceParams name="UserDatabase">
>         <parameter>
>                 <name>factory</name>
>                 <value>org.apache.catalina.users.MemoryUserDatabaseFactory
> </value>
>         </parameter>
>         <parameter>
>                 <name>pathname</name>
>                 <value>conf/tomcat-users.xml</value>
>         </parameter>
>     </ResourceParams>
>
>     <Resource auth="Container" name="jdbc/taaDataSource" scope="Sharable"
> type="javax.sql.DataSource"/>
>         <ResourceParams name="jdbc/taaDataSource">
>                 <parameter>
>                         <name>driverClassName</name>
>                         <value>oracle.jdbc.driver.OracleDriver</value>
>                 </parameter>
>                 <parameter>
>                         <name>url</name>
>                         <value>jdbc:oracle:thin:@URLGOESHERE
> :PORTNUMBERGOESHERE:OR10g2</value>
>                 </parameter>
>                 <parameter>
>                         <name>username</name>
>                         <value>USERNAMEHERE</value>
>                 </parameter>
>                 <parameter>
>                         <name>password</name>
>                         <value>PASSWORDHERE</value>
>                 </parameter>
>                 <parameter>
>                         <name>MaximumIdleConnections</name>
>                         <value>15</value>
>                 </parameter>
>                 <parameter>
>                         <name>MaximumActiveConnections</name>
>                         <value>15</value>
>                 </parameter>
>                 <parameter>
>                         <name>MaximumWait</name>
>                         <value>1000</value>
>                 </parameter>
>         </ResourceParams>
>  </GlobalNamingResources>
>
>   <!-- A "Service" is a collection of one or more "Connectors" that share
>        a single "Container" (and therefore the web applications visible
>        within that Container).  Normally, that Container is an "Engine",
>        but this is not required.
>
>        Note:  A "Service" is not itself a "Container", so you may not
>        define subcomponents such as "Valves" or "Loggers" at this level.
>    -->
>
>   <!-- Define the Tomcat Stand-Alone Service -->
>   <Service name="Catalina">
>
>     <!-- A "Connector" represents an endpoint by which requests are
> received
>          and responses are returned.  Each Connector passes requests on to
> the
>          associated "Container" (normally an Engine) for processing.
>
>          By default, a non-SSL HTTP/1.1 Connector is established on port
> 8080.
>          You can also enable an SSL HTTP/1.1 Connector on port 8443 by
>          following the instructions below and uncommenting the second
> Connector
>          entry.  SSL support requires the following steps (see the SSL
> Config
>          HOWTO in the Tomcat 5 documentation bundle for more detailed
>          instructions):
>          * If your JDK version 1.3 or prior, download and install JSSE
> 1.0.2 or
>            later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
>          * Execute:
>              %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
> (Windows)
>              $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA
> (Unix)
>            with a password value of "changeit" for both the certificate
> and
>            the keystore itself.
>
>          By default, DNS lookups are enabled when a web application calls
>          request.getRemoteHost().  This can have an adverse impact on
>          performance, so you can disable it by setting the
>          "enableLookups" attribute to "false".  When DNS lookups are
> disabled,
>          request.getRemoteHost() will return the String version of the
>          IP address of the remote client.
>     -->
>
>     <!-- Define a non-SSL Coyote HTTP/1.1 Connector on the port specified
> during installation  -->
>     <Connector acceptCount="100" connectionTimeout="20000" debug="0"
> disableUploadTimeout="true" enableLookups="false" maxSpareThreads="75"
> maxThreads="150" minSpareThreads="25" port="80" redirectPort="8443"/>
>
>     <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
>     <Connector debug="0" enableLookups="false" port="8009"
> protocol="AJP/1.3" redirectPort="8443"/>
>
>     <!-- An Engine represents the entry point (within Catalina) that
> processes
>          every request.  The Engine implementation for Tomcat stand alone
>          analyzes the HTTP headers included with the request, and passes
> them
>          on to the appropriate Host (virtual host). -->
>
>     <!-- You should set jvmRoute to support load-balancing via JK/JK2 ie :
>     <Engine name="Standalone" defaultHost="localhost" debug="0"
> jvmRoute="jvm1">
>     -->
>
>     <!-- Define the top level container in our container hierarchy -->
>     <Engine debug="0" defaultHost="localhost" name="Catalina">
>         <DefaultContext>
>                   <ResourceLink global="jdbc/taaDataSource"
> name="jdbc/taaDataSource" type="javax.sql.DataSource"/>
>                   <ResourceLink global="help-tag-connector"
> name="help-tag-connector" type="java.lang.String"/>
>         </DefaultContext>
>
>         <!-- Global logger unless overridden at lower levels -->
>         <Logger className="org.apache.catalina.logger.FileLogger"
> prefix="catalina_log." suffix=".txt" timestamp="true"/>
>
>         <!-- This Realm uses the UserDatabase configured in the global
> JNDI
>         resources under the key "UserDatabase".  Any edits
>         that are performed against this UserDatabase are immediately
>         available for use by the Realm.  -->
>         <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
> debug="0" resourceName="UserDatabase"/>
>
>         <!-- Define the default virtual host
>         Note: XML Schema validation will not work with Xerces 2.2.
>         -->
>         <Host appBase="webapps" autoDeploy="true" debug="0"
> name="localhost" unpackWARs="true" xmlNamespaceAware="false"
> xmlValidation="false">
>
>                 <!-- Logger shared by all Contexts related to this virtual
> host.  By
>                      default (when using FileLogger), log files are
> created in the "logs"
>                      directory relative to $CATALINA_HOME.  If you wish,
> you can specify
>                      a different directory with the "directory"
> attribute.  Specify either a
>                      relative (to $CATALINA_HOME) or absolute path to the
> desired
>                      directory.-->
>                 <Logger className="org.apache.catalina.logger.FileLogger"
> directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/>
>
>         </Host>
>     </Engine>
>   </Service>
> </Server>
> [end server.xml]
>
> If there's anything else I need to show you, please let me know.  Thanks
> for your help!
>
> ==================
>
>
> What Datasource are you using?
>
> Brandon
>
> On 8/27/07, Leffingwell, Jonathan R CTR FRCSE, JAX 7.2.2 <
> jonathan.leffingwell.ctr@navy.mil <*
> mailto:jonathan.leffingwell.ctr@navy.mil*<jonathan.leffingwell.ctr@navy.mil>>
> > wrote:
>
>         I'm using IBM RAD 6.0, iBatis 2.0.3 (we're not authorized to move
> to anything beyond that), and the DBMS is Oracle 10g.  I'm having problems
> that I've never had before with Oracle 9i, and I wonder if there is a
> solution someone can help me with.
>
>         In a nutshell, I have a method called processITS that calls a
> different method (insertITS), and the insertITS method performs a number of
> SELECT, INSERT, UPDATE, and DELETE calls, depending on the values of certain
> variables.  It looks kinda like this:
>
>         processITS (List laborList)
>         {
>           try{
>           // Bunch of stuff here.
>           transactionManager.startTransaction();
>           itsLaborMgr.insertITSLabor(itsLaborList);
>
>           //Loop through itsLaborList to see if any errors were found.
>           If (noErrors)
>           {
>             transactionManager.commitTransaction();
>           }
>           } catch Exception {
>              //Exception stuff here.
>           } finally {
>             transactionManager.endTransaction();
>           }
>         }
>
>         insertITS (itsLaborList)
>         {
>           Iterator iterator = itsLaborList.iterator();
>           while(iterator.hasNext())
>           {
>              //Business rule checks. If errors found, then get out of
> WHILE loop.
>              If (errors)
>              {
>                 //Add errors to itsLaborList to return to processITS. Get
> out of this method.
>              }
>              else
>              {
>                 //No errors, so do a bunch of SELECT/INSERT/UPDATE/DELETE
> calls.
>              }
>           }//END-while
>         }
>
>         As you can see, I only have the COMMIT in one place, and that's in
> the processITS method.  When I set up my debug stop, I see that the COMMIT
> never gets called when there are errors coming back from insertITS (which is
> correct).  YET when I look in the database, the COMMIT happened anyway.
>
>         I've searched here, and I thought this might do the trick:
>
>         [Contents of sql-map-config.xml]
>
>         <?xml version ="1.0" encoding= "UTF-8" standalone="no" ?>
>         <!DOCTYPE sqlMapConfig
>                                 PUBLIC "-//ibatis.apache.org//DTD SQL Map
> Config 2.0//EN"
>                         " *
> http://ibatis.apache.org/dtd/sql-map-config-2.dtd*<http://ibatis.apache.org/dtd/sql-map-config-2.dtd><
> *http://ibatis.apache.org/dtd/sql-map-config-2.dtd*<http://ibatis.apache.org/dtd/sql-map-config-2.dtd>>
> " >
>
>
>         <sqlMapConfig>
>
>           <!--
>                 This was removed and code added to the BaseTaaManager
> Constructor
>                 to read this properties file and pass the properties into
> the
>                 daoManagerBuilder to populate the parameters
>
>                 <properties
> resource="blahblahblah/config/database.properties"/>
>
>                 The above is no longer required - configure in server.xml
>           -->
>
>           <settings
>             cacheModelsEnabled= "false"
>             enhancementEnabled= "false"
>                 lazyLoadingEnabled="false"
>             maxSessions= "64"
>             maxTransactions= "32"
>             maxRequests= "512"/>
>           <transactionManager type="JDBC" commitRequired ="true">
>                 <property name ="DefaultAutoCommit" value= "false"/>
>                 <property name ="SetAutoCommitAllowed" value= "false"/>
>             <dataSource type="${type}">
>                         <property value ="${datasource}" name=
> "DataSource"/>
>                         <property value ="${driver}" name= "JDBC.Driver"/>
>
>                     <property value="${url}" name ="JDBC.ConnectionURL"/>
>                         <property value ="${username}" name= "
> JDBC.Username"/>
>                         <property value ="${password}" name= "
> JDBC.Password"/>
>             </dataSource >
>           </transactionManager >
>
>           <sqlMap resource="blahblahblah /sql/taaSQL.xml"/>
>         </sqlMapConfig>
>
>         [End of sql-map-config.xml]
>
>         Specifically, I thought adding DefaultAutoCommit and
> SetAutoCommitAllowed would work, but upon redeployment, I see that nothing's
> different, i.e. the COMMIT is still happening.  In other words, an
> AutoCommit is happening somewhere (since there is no other COMMIT, and
> COMMIT is never being called within the code), but I don't know where.
> HELP!
>
>         Jonathan
>
>
>
>

Mime
View raw message