UserTransaction or JDBC transaction

Hi,
please give suggestions...
We are using a application server with connection pooling
jsp and servlets are used in project
for transactions Is userTransaction is better or JDBC transaction is better
userTransaction may be implemented like this
try
getUserTransaction
transaction.begin
execute queries
transaction.commit
catch()
transaction.setRollbackOnly
JDBC Transaction may be implemented like this
connection.autoCommit=false
try
execute queries
connection.commit
catch()
connection.rollback
which is better for scalability and performance when we have to use transactins
in jsp/servlets
regards

Hi,
You are talking about using programmatic transactions in J2EE applications.
When developing J2EE applications, you are recommended to use the transaction mechanism provided by the application servers.
Sometimes, JDBC transaction can undertake the whole task. However, using JTA (Java Transaction APIs) is the better choice.
Especially when you are going to develop a lot of components (JavaBeans/ EJBs).
Imangine if a transaction is to be finished after the coroperation of serveral objects(JavaBean/ EJB instances).
How can you control the begining and the ending of the transaction by puting codes in these programs?
But it is very easy to input JTA codes (just like userTransaction etc.) to implement it.
Therefore, to use JTA is more convinient.
Additionally, J2EE specifications recommend to use declarative transactions in EJBs. Thus transaction management could be more flexible.
Good luck.
Gary Wang
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support/

Similar Messages

  • UserTransactions without JDBC?

    Hi!
    Is it possible to use UserTransactions without JDBC and EJBs.
    I tried this (with WebSphere 3.5):
    int i=1;
    utx.begin();
    i++;
    utx.rollback();
    System.out.println(i);
    But the rollback does not work.
    The output is 2 and not 1.
    Is there a possibility to do something like that?
    cu...
    Torsten

    Hi,
    A transaction in JTA only spans work done through javax.transaction.xa.XAResource instances.
    The rollback will only work for resources that are enlisted with the transaction.
    In fact, an instance of XAResource in a handle to a transactional context on some object. To make it work for your case, you would have to implement an object that encapsulates the i counter, and is able to return an XAResource that can be enlisted with the transaction.
    The rollback method would then restore the previous value of i.
    Making this work in a valid way would require logging the state of the object as well, since XAResources can be prepared (meaning that the work can still be rolled back, but needs to be recoverable after a crash).
    Best,
    Guy

  • Setting JDBC Transaction Isolation

    https://community.jboss.org/wiki/ConfigDataSources
    As explained in the above URL, with JBoss, you can set the JDBC transaction isolation level in the xml file that contains the JDBC connection information.
    I've been doing some googling, but I'm not clear on how this can be done with WebLogic. Is there some kind of external file where you can set the JDBC transaction isolation level as with JBoss, or is this some kind of change that can only be made in the application code or in some file contained within the application archive file (ear, war, etc.)?

    You can set the isolation in the deployment override weblogic-ejb-jar.xml
    - http://docs.oracle.com/cd/E21764_01/web.1111/e13719/ejb_jar_ref.htm#i1116237
    - http://docs.oracle.com/cd/E21764_01/web.1111/e13719/ejb_jar_ref.htm#i1219612

  • A jdbc transaction error occur

    Hi Everybody
    A jdbc transaction error occur when I deploy the application on the server .
    Below is the stack trace
    #SAP J2EE Engine JTA Transaction : [03bfffffffd3a000ffffffc0]####Application [13]##0#0#Error#1#/System/Audit#Java###Exception #1#com.sap.engine.services.dbpool.exceptions.BaseSQLException: Cannot commit transaction from this connection of "YTSQLS2K" DataSource. This resource participates in a local or distributed transaction.
    #SAP J2EE Engine JTA Transaction : [03bfffffffd3a000ffffffc0]####Application [13]##0#0#Error#1#/System/Audit#Java###Exception #1#com.sap.engine.services.dbpool.exceptions.BaseSQLException: Cannot initiate transaction from a connection of "YTSQLS2K" DataSource. Local or distributed transaction has already started.
    #SAP J2EE Engine JTA Transaction : [03bfffffffd3a000ffffffc0]####Application [13]##0#0#Error#1#/System/Audit#Java###Exception #1#com.sap.engine.services.dbpool.exceptions.BaseSQLException: Cannot commit transaction from this connection of "YTSQLS2K" DataSource. This resource participates in a local or distributed transaction.
    Any idea about it
    I use the jdbc version in datasource <jdbc-1.x>
    is there a need to replace it with <jdbc-2.0>
    Thank You
    Syed Saifuddin

    Hibernate allows you to choose transaction manager. As Nikolay pointed out, in a JEE envirnment it's prefferable to use JTA transactions. All you need to do is to configure hibernate to use a JTA transaction manager. It is all written in the Hibernate documentations. See
    http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#configuration-j2ee
    and
    http://www.hibernate.org/42.html#A5 .
    The relevant properties that need to be set in the configuration are:
    hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory
    and
    hibernate.transaction.manager_lookup_class=<Class that knows how to lookup>
    You need to implement a class that knows how to lookup user transaction in SAP J2EE Egnine.
    The class must extend org.hibernate.transaction.JNDITransactionManagerLookup and only override its abstract method getName (simply returning the lookup string). Then provide the fully qualified name as value of the property and make sure that Hibernate can load the class.
    That should work.
    HTH
    -Georgi
    Message was edited by:
            Georgi Pavlov

  • Grouping JMS & JDBC transaction with JTA outside of an app server

    hi,
    Can anyone help me or direct me to some code/configuration that shows how to combine JDBC + JMS into one distributed transaction outside of an app server.
    thanks in advance
    michael

    Hi,
              Well, transaction guru's please correct what I say here, but from what I
              understand of your problem here goes:
              If you begin a user transaction your are going to be starting a distributed
              transaction. That's the point of doing it, and hence that's why you have an
              XA. You have more than once resource participating in a transaction, and
              that is what UserTransaction was created for. You can't do it with a local
              transaction, which is for one resource only. I hope that answers "why
              would I need a XA". Even if both resources are hosted by WebLogic, you have
              explicitly asked for a UserTransaction...WL will optimize it if both are on
              same server, but still.. In addition, if you have a true XA data source and
              connection pool, then I would imagine that WL would list the transaction
              system of the DB too....whcih won't be local.
              As for your other problem, it seems to me that you have a connection pool of
              connections that are not XA-aware. If you set the attribute in the
              datasource and enable emulation, then the datasource becomes XA aware, but
              only sort of. WL handles the XA behaviour of that resource, but with
              limitations (you can't have more than one resource with XA emulation in the
              same Tx). If you are using a connection factory with a different store that
              uses XA-emulation, as well as straight JDBC from yet another pool using XA
              emulation, then you will also get problems. Best is to use a real driver
              that supports XA.
              Regards,
              Jon
              

  • JDBC transactions in EJB 3.0

    We have an EJB 3.0 method that call some jdbc DAO methods. This DAO methods called from controller (servlet) works fine, but when called from EJB method raise the following exception:
    "java.sql.SQLException: Cannot call Connection.commit in distributed transaction. Transaction Manager will commit the resource manager when the distributed transaction is committed."
    I think it is a JTA related error. I don't want to use JTA because I can't modify DAO (its a third party library).
    I've tried annotation @TransactionAttribute(value=SUPPORTS) in the EJB method without success.
    There is anyway to say EJB 3.0 not use JTA?
    Thank's

    Frank, yes, I can modify if it is necessary the datasource but, how can I say in the xxxx-jdbc.xml not to use JTA transactions when this data source is called inside a ejb 3.0 method?
    I'm using Jdev11g and the integrated Web Logic Server.
    Thank's

  • JDBC  Transaction is no longer active - status: 'Marked rollback'

    I'm getting the folowing issue, we are not seeing this issue if we recycle the WLS
    Using WLS V10.3.3
    Can any one suggest on this issue, how to reslove this
    85417.772: [Full GC [PSYoungGen: 117504K->0K(234880K)] [PSOldGen: 662564K->665699K(700416K)] 780068K->665699K(935296K) [PSPermGen: 133284K->132438K(225280K)], 30.2876423 secs] [Times: user=31.23 sys=0.68, real=30.32 secs]
    java.sql.SQLException: The transaction is no longer active - status: 'Marked rollback. [Reason=weblogic.transaction.internal.TimedOutException: Transaction timed out after 39 seconds
    BEA1-600C65F8B23E363DFDF0]'. No further JDBC access is allowed within this transaction.
    at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledBack(JTSConnection.java:193)
    at weblogic.jdbc.wrapper.JTSConnection.checkConnection(JTSConnection.java:209)
    at weblogic.jdbc.wrapper.ResultSet.preInvocationHandler(ResultSet.java:99)
    at weblogic.jdbc.wrapper.ResultSet_oracle_jdbc_driver_OracleResultSetImpl.next(Unknown Source)
    at com.vzw.pos.cmw.ejb.service.UserProfileService.getNewUserId(Unknown Source)
    at com.vzw.pos.cmw.ejb.utils.CMWEjbUtil.createUserProfileVO(Unknown Source)
    at com.vzw.pos.cmw.ejb.utils.CMWEjbUtil.createRosterVO(Unknown Source)
    at com.vzw.pos.cmw.ejb.service.AdministrationBean.getRostersByUserId(Unknown Source)
    at com.vzw.pos.cmw.ejb.service.Administration_ujnwz8_ELOImpl.__WL_invoke(Unknown Source)
    at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:39)
    at com.vzw.pos.cmw.ejb.service.Administration_ujnwz8_ELOImpl.getRostersByUserId(Unknown Source)
    at com.vzw.pos.cmw.action.CMWTopFrameAction.setUserRoleInSession(Unknown Source)
    at com.vzw.pos.cmw.action.CMWTopFrameAction.changeLocation(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor190.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
    at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at com.vzw.pos.cmw.filters.CMWFilter.doFilter(Unknown Source)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3710)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3676)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2272)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2178)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    <Aug 23, 2013 10:41:53 AM EDT> <Warning> <Socket> <BEA-000450> <Socket 298 internal data record unavailable (probable closure due idle timeout), event received -32>
    <Aug 23, 2013 10:41:53 AM EDT> <Warning> <Socket> <BEA-000450> <Socket 286 internal data record unavailable (probable closure due idle timeout), event received -32>
    <Aug 23, 2013 10:41:56 AM EDT> <Warning> <Socket> <BEA-000450> <Socket 299 internal data record unavailable (probable closure due idle timeout), event received -32>
    <Aug 23, 2013 10:42:51 AM EDT> <Warning> <Socket> <BEA-000450> <Socket 286 internal data record unavailable (probable closure due idle timeout), event received -32>

    Here is DS configuration
    Initial Capacity:                  75
    Maximum Capacity:                  75
    Capacity Increment:                    1
    Seconds to trust an idle pool connection:     10
    Shrink Frequency:                    900
    Enable Connection Leak Profiling:          False
    Enable Connection Profiling:               False
    Test Frequency:                         120 seconds
    Test Connections on Reserve:               True
    Connection Reserve Timeout:               10 seconds
    Connection Creation Retry Frequency:         1
    Inactive Connection Timeout:               60 second
    Maximum Waiting for Connection:               2147483647
    Statment Cache Type:     LRU
    Statment Cache Size:     10
    Connection Creation Relay Frequency:      1
    Remove Infected Connections Enabled:      True
    Wrap Data types:     True
    Ignore In-use connections:     True

  • Basic JDBC transactional question

    Hello all,
    I have (what I believe) is a basic transactional JDBC question.
    Here's what I want to do:
    begin transaction
    select a row from a table where (some condition).
    that row may or may not exist.
    if the row exists: update the row
    else if the row does not exist, insert a new row
    end transaction
    I want this entire thing to be atomic .. I don't want the select to complete, then have something else come in there before the update/insert takes place.
    I'm using MySQL .. I seem to remember hearing about some proprietary MySQL command which would do a SELECT + UPDATE atomically .. which would be fine, but I can't find it.
    Wrapping this with a row-level lock would be fine too .. I'm just not sure how to do that in JDBC.
    Thanks!
    -d

    By thte way, and not that it helps the orignal poster, who's using MySQL, but Oracle has a proprietary MERGE statement that does "insert or update" in one go. For example:
    MERGE INTO bonuses D
       USING (SELECT employee_id, salary, department_id FROM employees
       WHERE department_id = 80) S
       ON (D.employee_id = S.employee_id)
       WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
         DELETE WHERE (S.salary > 8000)
       WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
         VALUES (S.employee_id, S.salary*0.1)
         WHERE (S.salary <= 8000);

  • JDBInsight 2.0 Released - True JDBC Transaction Analysis !!!

    Check out the new product release and revised documentation at:
    http://www.jinspired.com/products/jdbinsight/downloads/index.html
    PRESS RELEASE
    =============
    DUBLIN, IRELAND - 29th October, 2003 - JInspired (www.jinspired.com), a leader
    in J2EE(tm) transaction analysis, today announced JDBInsight 2.0, the next generation
    of J2EE performance management products from JInspired.
    JDBInsight is the first product to effectively integrate Java profiling information
    with JDBC/SQL transaction analysis. Version 2.0 has numerous features derived
    from its support of the Java VM Profiling Interface(JVMPI) such as Java call stack
    analysis, cpu, blocking and waiting measurements at the transaction path level.
    Clock measurements are adjusted for blocking, waiting and gc pauses. New features
    in this release
    - New console user interface: Many new informative visualizations of J2EE transactions
    and performance execution profiles have been added. Including call stack graphs,
    entry point tree maps, sequence diagrams, call stack and transaction transcripts.
    Additional views included allow for navigation of the performance profile via
    database table or column, Java package, class, or method, technology classification,
    SQL tokens, or transaction entry points.
    - Java call stack classification engine: Developers, testers, database and J2EE
    server administrators can now better understand the interaction of various Java
    enterprise technologies with corporate databases. Classifications are available
    for Java enterprise technologies such as EJB, Hibernate, JDO, JMS, JSP, Servlets,
    JTS, JDBC, and Struts.
    - Terminal services: The terminal services add-on provides a quick and easy way
    to communicate with multiple servers without having to use a graphical user interface.
    This facilitates the streamlined connection, activation and deactivation of profiles
    on local or remote servers with the ability to control multiple servers from a
    single terminal. The terminal environment provides a powerful environment to create
    and schedule snapshot information, in order to monitor servers at regular intervals,
    with the ability to store and retrieve snapshots from any mounted drive, as well
    as providing a rich set of commands, that can be executed from saved scripts,
    to assist in analysis of this highly detailed profile data.
    - Transaction demarcations: JDBInsight 2.0 is the first performance management
    product to have the ability to detect and present resource transaction demarcations
    - allowing visual sub-transaction identification.
    - Resource Management: JDBInsight keeps counters representing objects states for
    each JDBC interception point create a resource object. When a JDBC resource changes
    state the allocation site counters are updated. This helps to pinpoint source
    code locations where resource objects are created and not closed properly or freed
    from memory. Because an interception is a combination of call stack and SQL the
    view caters for generic J2EE application frameworks which create objects based
    on application parameters and callers.
    - Xml export: Various statistical measurements can be viewed in Xml format and
    copied into applications for custom report generation.
    - Server options: Additional system properties to customize the small amount of
    overhead added during runs.
    About JDBInsight
    JDBInsight is an innovative enterprise development product, aimed at simplifying
    the performance tuning and testing of J2EE(tm) applications, which access data
    through the Java Database Connectivity (JDBC(tm)) API. JDBInsight analyses the
    access of enterprise data by J2EE(tm) client-, web-, and bean containers. The
    analysis can encompass transaction executions, from multiple J2EE(tm) containers.
    JDBInsight captures timing and execution information for enterprise data accessed
    by Servlets, JavaServer Pages, Session- and Entity Beans using JDBC(tm) or an
    Entity Bean using a container's persistence engine. JDBInsight can also profile
    non-J2EE applications that access enterprise data through the JDBC(tm) API.
    What distinguishes JDBInsight from other profiling and performance management
    tools on the market is that JDBInsight provides analysis from a sequence perspective
    instead of simply showing a call tree. Inefficiencies in J2EE applications occur
    mainly at the transaction level such as repeating the execution of a particular
    SQL locally and globally. JDBInsight facilitates the recognition of database interaction
    patterns that exhibit inefficiencies when viewed in terms of the sequential execution
    of a business and/or resource transaction.
    About JInspired
    JInspired located in Ireland, delivers JDBInsight, a comprehensive solution for
    Application Performance Tuning and Testing that focuses directly on early identification
    within the development and testing lifecycle. Jinspired offers sophisticated analytical
    tools, that capture transactional behaviour and performance timing information,
    across multiple containers in a single console, and presents this information
    intuitively to the user "Visualizing the Invisible".

    Check out the new product release and revised documentation at:
    http://www.jinspired.com/products/jdbinsight/downloads/index.html
    PRESS RELEASE
    =============
    DUBLIN, IRELAND - 29th October, 2003 - JInspired (www.jinspired.com), a leader
    in J2EE(tm) transaction analysis, today announced JDBInsight 2.0, the next generation
    of J2EE performance management products from JInspired.
    JDBInsight is the first product to effectively integrate Java profiling information
    with JDBC/SQL transaction analysis. Version 2.0 has numerous features derived
    from its support of the Java VM Profiling Interface(JVMPI) such as Java call stack
    analysis, cpu, blocking and waiting measurements at the transaction path level.
    Clock measurements are adjusted for blocking, waiting and gc pauses. New features
    in this release
    - New console user interface: Many new informative visualizations of J2EE transactions
    and performance execution profiles have been added. Including call stack graphs,
    entry point tree maps, sequence diagrams, call stack and transaction transcripts.
    Additional views included allow for navigation of the performance profile via
    database table or column, Java package, class, or method, technology classification,
    SQL tokens, or transaction entry points.
    - Java call stack classification engine: Developers, testers, database and J2EE
    server administrators can now better understand the interaction of various Java
    enterprise technologies with corporate databases. Classifications are available
    for Java enterprise technologies such as EJB, Hibernate, JDO, JMS, JSP, Servlets,
    JTS, JDBC, and Struts.
    - Terminal services: The terminal services add-on provides a quick and easy way
    to communicate with multiple servers without having to use a graphical user interface.
    This facilitates the streamlined connection, activation and deactivation of profiles
    on local or remote servers with the ability to control multiple servers from a
    single terminal. The terminal environment provides a powerful environment to create
    and schedule snapshot information, in order to monitor servers at regular intervals,
    with the ability to store and retrieve snapshots from any mounted drive, as well
    as providing a rich set of commands, that can be executed from saved scripts,
    to assist in analysis of this highly detailed profile data.
    - Transaction demarcations: JDBInsight 2.0 is the first performance management
    product to have the ability to detect and present resource transaction demarcations
    - allowing visual sub-transaction identification.
    - Resource Management: JDBInsight keeps counters representing objects states for
    each JDBC interception point create a resource object. When a JDBC resource changes
    state the allocation site counters are updated. This helps to pinpoint source
    code locations where resource objects are created and not closed properly or freed
    from memory. Because an interception is a combination of call stack and SQL the
    view caters for generic J2EE application frameworks which create objects based
    on application parameters and callers.
    - Xml export: Various statistical measurements can be viewed in Xml format and
    copied into applications for custom report generation.
    - Server options: Additional system properties to customize the small amount of
    overhead added during runs.
    About JDBInsight
    JDBInsight is an innovative enterprise development product, aimed at simplifying
    the performance tuning and testing of J2EE(tm) applications, which access data
    through the Java Database Connectivity (JDBC(tm)) API. JDBInsight analyses the
    access of enterprise data by J2EE(tm) client-, web-, and bean containers. The
    analysis can encompass transaction executions, from multiple J2EE(tm) containers.
    JDBInsight captures timing and execution information for enterprise data accessed
    by Servlets, JavaServer Pages, Session- and Entity Beans using JDBC(tm) or an
    Entity Bean using a container's persistence engine. JDBInsight can also profile
    non-J2EE applications that access enterprise data through the JDBC(tm) API.
    What distinguishes JDBInsight from other profiling and performance management
    tools on the market is that JDBInsight provides analysis from a sequence perspective
    instead of simply showing a call tree. Inefficiencies in J2EE applications occur
    mainly at the transaction level such as repeating the execution of a particular
    SQL locally and globally. JDBInsight facilitates the recognition of database interaction
    patterns that exhibit inefficiencies when viewed in terms of the sequential execution
    of a business and/or resource transaction.
    About JInspired
    JInspired located in Ireland, delivers JDBInsight, a comprehensive solution for
    Application Performance Tuning and Testing that focuses directly on early identification
    within the development and testing lifecycle. Jinspired offers sophisticated analytical
    tools, that capture transactional behaviour and performance timing information,
    across multiple containers in a single console, and presents this information
    intuitively to the user "Visualizing the Invisible".

  • JMS and JDBC Transaction

    I have recently tried using the JMS interface for AQ and I have discovered that the queue connection is a separate JDBC connection even if you create a queue connection using an OracleConnection. Is there a workaround for this? It seems a bit strange to have two connections open to the database and be forced to use an XA session in order to get the commits synchronized. Any ideas ? Below is some sample code I am using:
    queueConnection = AQjmsQueueConnectionFactory.createQueueConnection((OracleConnection)connection);
    queueConnection.start();
    QueueSession queueSession = queueConnection.createQueueSession(true, Session.CLIENT_ACKNOWLEDGE);
    AQjmsSession aqs = (AQjmsSession)queueSession;
    Queue queue = aqs.getQueue("TEST_SCHEMA", "TEST_QUEUE");

    Hello,
    What version are you using of the jar files? What version of the database are you using?
    From what I recall the example in <Note:301434.1> successfully reused an existing JDBC connection.
    I would be interested to see a more complete code example if this is not helpful.
    Thanks
    Peter

  • JDBC transaction isolation

    Isolation levels are:
    commited, repeatable read, uncomitted and serializable.
    As a Java programmer, where will we specify these attributes?

    kasim wrote:
    I am using just JDBC, when i program using JDBC where i need to specify these?Sorry about the previous comment. I couldn't resist.
    Anyway, see java.sql.Connection and set/get TransactionIsolation: http://java.sun.com/javase/6/docs/api/java/sql/Connection.html

  • JDBC Transaction - Exception management

    Does anybody know how to catch ALL the SQL errors that could appear in a transaction composed for instance of 10 insert ?

    List sqlExceptions = new ArrayList();
    for(int i=0; i<commands.length; i++) {
      try {
        getStatement().executeUpdate(command);
    } catch(SQLException ex) {
    sqlExceptions.add(ex);

  • Jdbc transaction

    Hi! Sorry for my English.
    Can you help me with database transaction in Java.
    I have a mysql db and i create a java class that need to work with transaction.
    I tried with
    Connection connection= new Connessione().connect();
    connection.setAutoCommit(false);
    Statement db = connection.createStatement(
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    db.execute("update test _table set test=2");
    My problem is that if i run this application without execute the commit
    when i try to update the table test_table i can't because it is in lock.
    Then i have an other application in cuncurrency, this can't work until the first doesn't commit.
    CAN you help me with an example?
    THANKS;

    I don't understand;
    For example client1 start a transaction , do an update and wait that user
    press a button to commit;
    if in the meantime client2 start its transaction, do an insert and commit i don't like that client2 suspend until user1 press a button;
    in other words i need transaction for have atomic operation and rolled back if an error occur.

  • Distributed transactions/jdbc problem WL60

    Hi
              Our company has aworking application running on WLS5.1sp9.
              Im in the process of migrating it to WL6.0sp2.
              Our domain has 2 clusters each running 2 servers:
              1) servlet engines (handling http requests from clients, running servlets
              and jsp's)
              2) ejb containers (runnigour entities and session beans, working with Oracle
              8i database using connection pool and TxDataSource)
              The scenario:
              - a client request invokes a servlet on one of the servlet engines.
              - the servlet opens a jndi context to one of the ejb containers
              - the servlet open a transaction on a UserTransaction stub on that ejb.
              - then the servlet calls an entity bean using a home interface looked up
              using the same context.
              - the entity bean uses DataSource lookup in its own servers jndi to rerieve
              a connection.
              and then i get the following exception:
              java.sql.SQLException: No default driver for database type:
              jdbc:weblogic:jts
              at
              weblogic.jdbcbase.t3.Driver.seeIfWeNeedToInferDriverNameAndUrlFrom(Driver.ja
              va:456)
              at weblogic.jdbcbase.t3.Driver.getAllPropsFrom(Driver.java:255)
              at weblogic.jdbcbase.t3.Driver.connect(Driver.java:75)
              at weblogic.jdbcbase.jts.Driver.createRemoteConnection(Driver.java:199)
              at weblogic.jdbcbase.jts.Driver.connect(Driver.java:134)
              at
              weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java
              :44)
              at com.unisfair.util.DBHelper.getConnection(DBHelper.java:43)
              the transaction toString() gives:
              transaction=(IdHash=7541556,Name = [EJB
              UserBeanImpl.generateSessionSuffix()],Xid=2:b53da78d3c1badbb,Status=Active,n
              umRepliesOwedMe=0,numRepliesOwedOthers=1,seconds since begin=0,seconds
              left=30,activeThread=Thread[ExecuteThread: '8' for queue: 'default',5,Thread
              Group for Queue:
              'default'],ServerResourceInfo[weblogic.jdbc.jts.Connection]=(state=new,assig
              ned=none),SCInfo[ejb2]=(state=active),SCInfo[servlet2]=(state=active),SCInfo
              [ejb1]=(state=active),properties=({weblogic.transaction.name=[EJB
              UserBeanImpl.generateSessionSuffix()], weblogic.jdbc=t3://10.0.0.31:7007}))
              However the error happens on the other ejb server 10.0.0.33:7007
              It seems that the jts driver tries to get a remote connection on the server
              that coordinates the transaction but uses the deprecated t3 driver.
              I hope someone can help us since this problem is a good enough reason for us
              not moving on to WL6.0 we also looked at WL6.1 Beta and theres nothing new
              about it either.
              thanks
              Dror Last
              Senior Software Engineer
              Unisfair Inc.
              12 Yad Haruzim St. Tel Aviv 67778 Israel
              Tel: +972-3-5373738 Ext. 243
              Fax: +972-3-5373731
              GSM: +972-55-723710
              mailto:[email protected]
              http://www.unisfair.com/
              

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JDBC_TX ():
    In the readme file of Oracle JDBC drivers 8.1.6.0.1 (http://technet.oracle.com/software/tech/java/sqlj_jdbc/files/Readme_01.txt)
    it mentioned that it supports "distributed transactions".
    As I understand, JDBC transaction is connection based and uses Oracle internal transaction manager. In order to do "distributed transactions", I must have at least two connections open at the same time each to its own database instance. How does the two connections coordinate the transactions? I thought in order to support "distributed transactions", one has to build a higher layer to encapsulate the two connections and therefore coordinate the distributed transactions. Any examples will be welcome.<HR></BLOCKQUOTE>
    The two branches of the transaction are coordinated using 2-phase commit.
    For samples look under
    $ORACLE_HOME/jdbc/demo/samples/oci8/jdbc20-samples/
    null

  • JDBC, JMS and EJB transactions - possible problem?

    Hello,
              I am using Oracle 9, Weblogic 8.1 SP 4, MyEclipse and
              XDoclet.
              In my current project I have the following piece of code
              in one of my message driven beans (code cited as pseudocode
              without unnecessary details):
              * @ejb.bean name="MyMessageProcessor"
              * display-name="Display name for a MyMessageProcessor"
              * jndi-name="ejb/MyMessageProcessor"
              * description="Bean MyMessageProcessor"
              * destination-type="javax.jms.Queue"
              * transaction-type="Container"
              * acknowledge-mode="Auto-acknowledge"
              * subscription-durability="Durable"
              * generate="false"
              * @ejb.transaction type="Required"
              public class MyMessageProcessor implements MessageDrivenBean, MessageListener {
              public void onMessage(Message msg) {
                   try {
                        //obtaining connections to two different databases via JNDi
                        java.sql.Connection connOne =
                        ((DataSource)ctx.lookup("DataSourceOne")).getConnection();          
                        java.sql.Connection connTwo =
                             ((DataSource)ctx.lookup("DataSourceTwo")).getConnection();
                        // performing some UPDATEs and INSERTs on connOne and connTwo
                        // calling some other methods of this bean
                        //creating the reply JMS message and sending it to another JMS queue
                        Message msgTwo = this.createReplyMessage(msg)
                        this.queueSender.send(msgTwo);
                        //commiting everything
                        this.queueSession.commit();          
                   } catch (Exception ex) {
                   try {
                        if (this.queueSession!=null) this.queueSession.rollback();
                   } catch (JMSException JMSEx) {};     
                   this.context.setRollbackOnly();
              Some days ago (before the final remarks from my client) there used to be only one DataSource configurated on the basis of the
              connection pool with non-XA jdbc driver. Everything worked fine
              including the transactions (if anything wrong happend not only wasn't the replymessage sent, but also no changes were written
              to database and the incomming message was thrown back to the my bean's
              queue).
              When I deployed the second DataSource I was informed by an error message, that only one non-transactional resource may
              participate in a global transaction. When I changed both datasources
              to depend on underlying datasources with transatcional (XA) jdbc drivers, everything stopped working. Even if
              EJB transaction was theoretically successfully rolledbacked, the changed were written to the database
              and the JMS message wasn't resent to the JMS queue.
              So here are my questions:
                   1. How to configure connection pools to work in such situations? What JDBC drivers should I choose?
                   Are there any global server configurations, which may influence this situation?
                   2. Which jdbc drivers should I choose so that the container was able to rollback the database transactions
                   (of course, if necessary)?
                   3. Are there any JMS Queue settings, which would disable the container to send message back to the
                   queue in case of setRollbackOnly()? How should be the Queue configurated?
              As I am new to the topic and the deadline for the project seems to be too close I would be grateful
              for any help.
              This message was sent to EJB list and JDBC list.
              Sincerely yours,
              Marcin Zakidalski

    Hi,
              I found these information extremely useful and helpful.
              The seperate transaction for sending messages was, of course, unintentional. Thanks a lot.
              Anyway, I still have some problems. I have made some changes to the
              code cited in my previous mail. These changes included changing QueueSessions
              to non-transactional. I also set the "Honorate global transactions" to true.
              I am using XA JDBC driver. After setting "Enable local transactions" to false
              (I did it, because I assume that JDBC transactions should be part on the global
              EJB transaction) I got the following error:
              java.sql.SQLException: SQL operations are not allowed with no global transaction by default for XA drivers. If the XA
              driver supports performing SQL operations with no global transaction, explicitly allow it by setting
              "SupportsLocalTransaction" JDBC connection pool property to true. In this case, also remember to complete the local
              transaction before using the connection again for global transaction, else a XAER_OUTSIDE XAException may result. To
              complete a local transaction, you can either set auto commit to true or call Connection.commit() or Connection.rollback().
              I have also inspected the calls of methods of bean inside of onMessage() method just to check, whether
              the transactions are correctly initialized (using the weblogic.transaction.Transaction class).
              My questions are as follows:
              1. Any suggestions how to solve it? I have gone through the google answers on that problem and only
              thing I managed to realize that JDBC must start its own transaction. Is there any way to prohibit it
              from doing that? Can using setAutocommit(true/false) change the situation for better?
              2. How to encourage the JDBC driver to be a part of EJB transaction?
              3. As I have noticed each of ejb method has its own transactions (transactions have different
              Xid). Each method of the bean has "required" transaction attribute. Shouldn't it work in such
              way that if already started transaction exists it is used by the called method?
              4. The DataSources are obtained in my application via JNDI and in the destination environment I will have slight
              impact on the configuration of WebLogic. What is least problematic and most common WebLogic configuration which would
              enable JDBC driver to participate in the EJB transaction? Is it the WebLogic configuration problem or can it be
              solved programmically?
              Currently my module works quite fine when "enable local transactions" for DataSources is set to true, but this way
              I am loosing the ability to perform all actions in one transaction.
              Any suggestions / hints are more than welcomed. This message was posted to jdbc list and ejb list.
              Marcin

Maybe you are looking for

  • Adobe Photoshop CS6 Cannot be opened because of a problem

    My Photoshop (from my CS6) on Mac would not launch all of a sudden. I get the error title same as the title of this post. I tried clearing my launcher chance as well as re-installing. I am attaching the error report and two screenshots here. Any help

  • Where is the zen-eee repository?

    Hi, the Wiki mentions [1] the zen-eee repository as a source for EeePC specific packages, but apparently the repository is off-line? Does anyone know what happened to it? Peter [1] http://wiki.archlinux.org/index.php/Asu - he_EEE_901

  • ORA-31185 DOM NODES DO NOT BELONG TO THE SAME DOCUMENT

    Hi all, I developed an Oracle function that returns a XMLTYPE. In this function, I first created a node <ROOT> and I would like to append children nodes to this root node. To create children nodes I loop on a cursor and each iteration of this loop "b

  • Dynamic pop-up menus?

    Is there a way to create a pop-up menu in a cell from a list in another table within the same spreadsheet? That way when I update the table, the menu will update as well. I am trying to modify the Checking template and I want to be able to tag each e

  • Setting SGA_MAX_SIZE without setting SGA_TARGET

    RDBMS Version: 10.2.0.4 OS : Solart 5.10 We are currently facing some performance issues in one of our DBs. This DB has SGA Components individually set. For eg: DB_CACHE_SIZE is set to 2gb. I've noticed that SGA_MAX_SIZE = 6GB SGA_TARGET = Not setSho