Jta/jts

Hi
please clarify the following
the jta/jts service is specific to ejb container or is that for application server can we access that through jsp page with jta from jsop page if in case we have to use multiple databases from jsp and not use ejb
is jta/jts also implemented by web container
regards
Javid

Hi,
My approach would be to create some EJB's to access the database and host these in an J2EE server, then access these from your web applications.
EJB access to a database is much easier that putting the SQL statements in the WebPages and scales much better.
Nick

Similar Messages

  • Non J2ee use of JTA/JTS

    I am about to build a small J2SE Gui app but think I need to build in some Transactional features
    Can I use JTS/JTA outside of an AppServer environment - if so can your provide some pointers/docs/links
    for example in the JINI world there is a Transaction Management service (Mahalo) - is this really just JTA/JTS repackaged for the JINI world

    I'm not sure that just a JDBC Transaction wil sufficeI believe it's sufficient.
    I had in mind manipulating several classes worth of data via a GUIThe fact that you're doing it with a GUI is immaterial.
    If all goes well I can commit/update the underlying
    DB - otherwise I need to 'Rolback' the changes
    (potentially inside the DB & also in the GUI
    supporting classes)If you have good MVC separation it's not a problem.
    Sounds like you'll need to write your DAO persistence layer in such a way that several objects can participate in a transaction. No problem - do it in such a way that you pass a shared Connection between all the objects. Set auto commit to false for the Connection before you start, and then follow the usual idiom.
    If you commit, update the VO in the middle tier and ask the GUI to display them.
    If you rollback, the middle tier VO are unchanged and the GUI ends up displaying the original values again.
    %

  • JTA/JTS for non-EJB & non-J2EE server used

    I have a standalone java program which calls methods on 2 java classes (c1, c2) These are Non-EJB/non-RMI/non-CORBA plain java classes.
    the method in c1 updates table t1 in database db1
    the method in c2 updates table t2 in database db2
    I would like to use JTA for conducting a 2PC based transaction. I know this can be done in an application/server or a J2EE container environment because they have built-in Transaction Managers (TM). and one just has to use JNDI to look up the UserTransaction object and then define the transaction boundaries. However, how do I all the above if I don't have access to a J2EE server and an EJB server?
    It seems like I would have to use a standalone Transaction Manager (not bundled with the app-server).

    Hi,
    My company has just released a (beta!) version of a generic java transaction manager. Although it offers some lightweight beans as standard development model, this does not have to be the case: the core idea is an extensible and very advanced transaction kernel. JTA comptable.
    This software is server-oriented: the transactional kernel (which also does recovery) startup and shutdown events trigger the start (initialization) and shutdown of your 'extension' classes. This is necessary because otherwise your resources will not be recoverable: if the transaction manager starts up, then it will first do recovery, and therefore your resources need to be available.
    You can ask for a beta version through our website:
    http://www.atomikos.com
    Note, however: we did not yet implement the XA DataSources. Rather, we have a kind of 'external' stored procedures that allow distributed transactions over regular JDBC connections. You would have to implement your solution along this line, or wait for the XA datasources.
    If there proves to be a lot of demand,
    we can of course speed up development on XA. It is not a very big effort.
    Best regards,
    Guy
    Guy Pardon ( [email protected] )
    Atomikos Software Technology: Transactioning the Net
    http://www.atomikos.com/

  • JTS/JTA help

    Could anyone clear my thoughts regarding the following queries -
    1. Is JTS just a Specification or a concrete Implementation that could
    provided Transaction service.
    2. What is the differences between JTS and JTA?
    3. Could I use JTS/JTA directly in my application.
    4. Do I need any other software to make these API work.
    5. Who would be really be the provider of this API? Is there any provider
    from where I could download the libraries.
    Any insights from ur experiences would put me in high spirits :-)
    --Suresh
    [email protected]

    Hi,
    JTS is a specification, a 'Java-version' of the CORBA OTS specification.
    JTA is the interface for creating and using transactions inside one Java application (such as an application server).
    JTS is mainly for 'exporting' and 'importing' the same transaction in different VMs or even to/from CORBA applications that were written in a diffent language and run on a non-Java platform. JTS/OTS also has some interfaces for application-level transaction creation, but Java has the JTA as a simplified mechanism for doing that.
    About using JTA/JTS in your application directly: yes you can, but you may need some extra handling of XAResources that need setup. Atomikos has such a JTA, and also a JTS (but still in beta).
    You do not need extra APIs to make them work, except maybe for the databases or message queues that you want to connect to. For the JTS, you need a Java ORB.
    For more information: http://www.atomikos.com
    Best regards,
    Guy

  • Unit of work - commit - JTS

    Hi,
    I was looking at the example of ejb session in the toplink installation files.
    I noticed that after having acquire a uow, not any commit is done (I tested it with my application) and it works without a commit, is this because of the external transaction controller with weblogic?
    And another thing I'd like to understand, I call getActiveUnitOfWork() on my client session but is this the external controller which has started it? Third point does it start a new uow each time because I do not want to reuse the same uow after committing (but will it however works as no explicit commit like uow.commit() is done)?
    Vlad

    Vlad,
    When running in a container managed TX (JTA/JTS) environment the UnitOfWork.commit() has no real effect. The commit is managed through the TX call-backs from the container.
    The getActiveUnitOfWork returns a unique UnitOfWork per JTA TX. This is lazily created the first time it is required or asked for. When the JAT TX commits the UnitOfWork performs its commit cycle and is released. The next JTA TX will result in a new UnitOfWork.
    Doug

  • High-Level JTS/TopLink design question

    I've gone through the "using JTS with TopLink" docs, and it mostly makes sense. However, I still don't understand how TopLink "knows" when I call acquireUnitOfWork() whether or not I'm participating in a distributed 2PC transaction.
    Said another way:
    Let's say I've got an application based on TopLink (registering appropriate JTS stuff) that exposes an API that can be accessed remotely (RMI, SOAP, whatever).
    And, I've got another, separate application using a different persistence-layer technology (also supporting JTS) that also has an API.
    Now, I create a business method that uses the APIs from both of these applications, and I want them to participate in a single, distributed transaction.
    At a high level (source code is unnecessary), how does that work?
    Would the API need to support an ability to specifiy a TransactionContext or is this all handled behind the scenes by the 2 systems registering with the Transaction Service?
    If this is all handled through registration, how do these 2 systems know that these specific calls are all part of the same XA transaction?

    Nate,
    TopLink particiaptes in JTA/JTS transactions but dows not control them. When you configure TopLink to use the JTA/JTS services of the host application server you are deferring TX control to the J2EE container. TopLink will in this case register each acquired UnitOfWork in the current active TX from the container. The container will also ensure that the JDBC connection provided to TopLink is also bound by the active TX.
    In order to get 2PC you must register multiple resources into the same JTA TX. The TX processing during commit will then make the appropriate call backs to the underlying data source as well as the necessary call backs to listeners suchs as TopLink to have its SQL issued against the database.
    In short: The J2EE container manages the 2PC TX and TopLink is just a participant.
    Doug Clarke

  • JTA questions - help

    I am considering the use of Java Transaction API and I have a couple questions.
    What are any problems/considerations surrounding the use of JTA?
    What are some of the possible alternatives to the JTA/JTS method for transactions?
    Thank you

    Hi,
    One thing about JTA is that you would need a suitable connection management module to do the resource enlist/delist for you (otherwise you get to write low-level code in your programs).
    For example, you can try http://www.atomikos.com for a standalone JTA implementation that includes JDBC and JMS modules.
    JTS is only necessary if you want to extend your application and its transactions across multiple VMs, for instance if you have clusters of applications that invoke each other.
    For regular JDBC or JMS transactions, you can do fine with just JTA and no JTS.
    The typical alternative would be an EJB application server (which allows you to have transactions without explicitly calling JTA in your code); this may or may not be an overkill depending on what you want.
    Hope that helps,
    Guy

  • JTA book

    Hi
              I m looking for a good book that explains JTA, JTS, 2pC etc.
              Any recommendations ? I found a lot of J2EE books but most of them
              have very light treatment of JTA.
              Thanks
              =sam
              

    While they aren't java-specific, if you're looking for XA/2PC details,
              these 2 are good:
              Transaction Processing: Concepts and Techniques (Morgan Kaufmann Series
              in Data Management Systems)
              by Jim Gray, Andreas Reuter
              Principles of Transaction Processing
              by Philip A. Bernstein, Eric Newcomer (Contributor)
              -- Rob
              Sam wrote:
              > Hi
              >
              > I m looking for a good book that explains JTA, JTS, 2pC etc.
              >
              > Any recommendations ? I found a lot of J2EE books but most of them
              > have very light treatment of JTA.
              >
              > Thanks
              > =sam
              

  • How to access JDBC Resource registered in Sun Java System App Server ?

    I want to create a stand-alone JDBC application with Java SE using Swing technologies and JNDI technology. The purpose of using JNDI technology is to avoid change of Java Source Code every time I move the database to different location. This Java application will be used in a standalone PC installed with Windows XP Professional with no LAN / WAN connection. Of course, Internet connection is available with the PC.
    I use JavaDB to store the data tables and the location of the database is D:\E-DRIVE\SAPDEV. Tomorrow, if I move this database to C:\SAPDEV or any network drive, I do not want to change the Java Source code. I want to use JNDI which, if I am not wrong, helps developers to avoid manual change of Java source code whenever the database location is changed. Changes have to be made only in the JNDI Name which contains all relevant information about the database in order to get connection no matter where the database SAPDEV is stored; it can be placed under D:\E-DRIVE directory or C:\ directory of the hard disk. To implement my intention, I started developing Java application as per the steps mentioned below:
    Step 1:
    To proceed, first, I sought the help of Sun Java System Application Server Admin Console. I created JNDI object for Connection Pool using the menu path Common Tasks->Resources->JDBC->Connection Pools.
    JNDI Name : ABAPRPY
    Resource Type : javax.sql.DataSource
    Datasource class : org.apache.derby.jdbc.ClientDataSource
    Description : ABAP Program Repository
    The Connection Pool creation has options for General, Advanced and Additional Settings tabs and I made all the settings relevant to the database I created in D:\E-DRIVE\SAPDEV.
    To confirm whether the above settings are correct, I pressed the Ping push button which is available in the General tab of the connection pool creation screen. The system responded with the message Ping Succeeded.
    Step 2:
    I created a JDBC Resource using the menu path Common Tasks->Resources->JDBC->JDBC Resources.
    JNDI Name : jdbc/SAPDEV
    Pool Name : ABAPRPY
    Description : Database Connection for SAPDEV database
    Status : Enabled
    I can see all the above settings recorded in the domain.xml which is placed in the folder
    C:\Sun\AppServer\domains\domain1\config
    Step 3:
    I have made sure that Sun Java System Application Server is up and running in the background with JavaDB server. I created a Java Program making sure the following JAR files are included in the classpath:
    appserv-admin.jar
    appserv-ee.jar
    appserv-rt.jar
    javaee.jar
    fscontext.jar
    Plus, the lib directory of JDK 1.6 & C:\Sun\AppServer\domains\domain1\config
    Source code of the program is as follows: I used NetBeans IDE to create my project file.
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.naming.*;
    import javax.activation.DataSource;
    public class JNDILookup {
    public static void main(String[] args) {
    try {
    InitialContext initCtx = new InitialContext();
    DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/sapdev>");
    } catch (NamingException ex) {
    Logger.getLogger(JNDILookup.class.getName()).log(Level.SEVERE, null, ex);
    When I attempted to compile the above program in NetBeans IDE ,no compilation error reported. But while executing the program, I got the following run-time error message:
    SEVERE: null
    javax.naming.NameNotFoundException: No object bound for java:comp/env/jdbc/sapdev> [Root exception is java.lang.NullPointerException]
    at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:224)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:396)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at SAPConnect.JNDILookup.main(JNDILookup.java:21)
    Caused by: java.lang.NullPointerException
    at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
    ... 3 more
    Now, I want to come out of this situation; at the same time, I want to preserve the settings I have made in the Sun Java System Application Server Admin Console. That is, I want to programmatically access the data source using Connection Pool created in Sun Java System Application Server Admin Console.
    I request dear forum members to provide me an appropriate solution.
    Thanks and regards,
    K. Rangarajan.

    jay44 wrote:
    Bare in mind I am attempting the context.lookup() from inside the container (my code is in a session bean). I have accessed the server and have my bean "say hello" first to verify the bean works OK, then I call a method with this rather standard code:
    String jndiDataSourceName ="Second_EJB_Module_DataBase";
    Logger.getLogger(DynamicPU.class.getName()).log(Level.INFO,"Programatically acquiring JNDI DataDource: "+ jndiDataSourceName);
    InitialContext ctx;
    try {
    ctx = new InitialContext();
    ds =(DataSource)ctx.lookup("java:comp/env/jdbc/"+jndiDataSourceName);
    } catch (NamingException ex) {
    Logger.getLogger(DynamicPU.class.getName()).log(Level.SEVERE, null, ex);
    return "Exception generated trying to preform JDBC DataSource lookup. \n"+ex.toString();
    But when I run the code the server log shows the initial context is created Ok, but an exception is thrown becasue the resource name is not found:
    (and i have tried vriations of ctx.lookup("jdbc/"+jndiDataSourceName) etc etc
    You are fine here. It works in container because the InitialContext properties have been supplied already. That was the link I forwarded earlier. The InitialContext you create locally needs to locate the container JNDI. That is what the properties specify.
    Where I am confused is where you indicate the stack below is from the server log. So, you initiate a standalone (java main method) application, create an InitialContext, and you see the results in your app server log?
    LDR5010: All ejb(s) of [EJB_Module_1] loaded successfully!
    Programatically acquiring JNDI DataDource: Second_EJB_Module_DataBase
    The log message is null.
    javax.naming.NameNotFoundException: Second_EJB_Module_DataBase not found
    at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
    at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
    at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:192)...
    at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
    This is strange since I can see this resource (a JDBC connection named Second_EJB_Module_DataBase) is configured on the server from the server's admin console.
    That is why you can obtain a lookup from within the container (app server).
    For this lookup to work it may be that one must map the name inside an ejb-jar.xml deployed with the application, but I have also read some resources like jdbc connection should have a default name. Does anyone know if my lookup() should work without using an ejb-jar.xml mfile to explcitly map the reource for my application?
    Both EBJ's and data sources can be referenced via JNDI. It's a remote lookup (that is normally optimized if it is running in the same JVM). You should not have any dependencies on a JDBC data source being set-up on ejb-jar.xml. That file can of course impact your EJB's. However, data sources are normally set-up on a container-specific basis (e.g., you probably did it through a console, but there is a spec somewhere about how to set up a data source via a resource the app server looks for; it varies from app server to app server). However, once you have that container-specific data source set-up, JNDI operates vendor-neutral. You should be able to take the code above and move it to JBoss or Weblogic or Tomcat or whatever (this is an ideal, in practice, the vendors sometimes put a data source in a name you would not expect, but again, you can use their JMX console to see what the JNDI name is).
    (As I stated above if I have to use a deployment discriptor to get at this JNDI datasource, then solution is not "programmatic" as newly configured datasources could not be accessed without redeploying the entire application).
    As JSchell alluded to, you will always have at least something vendor-specific. JNDI itself (the code you wrote) is totally portable. However, you have to set the various JNDI environment properties to a given vendor's spec. Ideally, you should not need a vendor's actual InitialContext application, but it's a possibility. Once you can safely cast to Context, you should be vendor-neutral (if not, demand your money back).
    So that is exactly where I am stuck, trying to get the lookup to work and wondering if it should work without and xml file mapping the resource for my app.
    What we ended up doing for standalone was to provide our own JNDI. If you look at the open source project JOTM, there are examples on how to use that with XBean (if integrating with Spring, as we did), you can easily set up a data source that runs standalone exactly as you get in the container. Another benefit is you get full JTA/JTS support and the ability to run XA transactions. (This might all be alphabet soup, but the app server gives it to you, and this is the way we ended up doing the same: JNDI + JTA + JTS + XA). It ends up the same application code uses a "vanilla" InitialContext and all we have to do is write one or two xml files (one for our app server, a couple for JOTM), and our actual code works the same.
    I still think you have a shot at getting to the container's JNDI, just not using their full-blown app server JAR.
    I think there must be a simple way to do this with an ejb-jar.xml, I am no expert in JNDI, I could be missing something simple, I will keep at it and post an answer here if I come up with it.
    Thanks, jayIt is simple to code. Getting it to integrate with your app server, yes, that can be challenging. But it has nothing to do with EJB's. Write a simple test. Using nothing but DataSource and InitialContext. Let us know where you get stuck.
    - Saish

  • Trying to undestand container interoperability

    Hello !
    After a while of reading the different j2ee specs (EJB, JTA, JTS...), I
    thought I understood that it is possible for a bean in a container A to
    invoke a bean in a container B. The dialog between containers is supposed to
    be in RMI-IIOP.
    First question : how does it look like from the point of view of the calling
    bean ? does it perform a classic lookup like a normal EJB client ? In this
    case, the lookup must be performed on the JNDI server of container B no ?
    thus it is necessary to specify parameters when instanciating an
    InitialContext, no ?
    Second question : If the way the calling bean calls the bean in container B
    looks like what I wondered in my first question, how can transaction and
    security context be propagated to the container B ? Actually, if the bean A
    retrieves a stub from the JNDI of B and performs invocation of B, how can
    the B stub know that A is currently in a transaction in order to tell it to
    B ?
    Actually, while writing my questions, it looks like the B stub does not
    necessarily talks to container B by using RMI-IIOP. So, what bean A should
    do to make container A use RMI-IIOP to talk to B ?
    Forgive me if my questions are a bit confused, but I desperately want to
    know if and how it is possible to make two beans interoperate between
    different containers. And as per the EJB 2 spec, RMI-IIOP seems to be the
    solution, I'd like to understand how a bean can make use of this.
    Thanks for your patience
    Sylvain

    Thanks for your reply. I still have a couple of questions...
    "Andy Piper" <[email protected]> wrote in message
    news:[email protected]..
    "Sylvain Laurent" <[email protected]> writes:
    Correct, but the lookup actually happens via CosNaming. So the scenariois:
    >
    Client -> JNDI -> CosNaming -----------> IIOP ----------> CosNaming ->JNDI -> Server
    Your figure makes me think that the client instanciates an InitialContext
    with the default parameters, no ?
    And it has ejb-ref specially declared in its ejb-jar.xml ? Could you provide
    me with an example ?
    Transactional characteristics are specified in the exported IOR's and
    transactions are propagated via OTS.You mean that container B exports an IOR to container A, which in turns will
    know how to handle transactions when bean A invoke bean B, correct ?
    Because in the case where A makes a direct look-up of bean B with the JNDI
    of B, container A has no opportunity to know what's going on, correct ?
    >
    Actually, while writing my questions, it looks like the B stub does not
    necessarily talks to container B by using RMI-IIOP. So, what bean Ashould
    >
    Why not?Because, for instance WLS uses its own t3 protocol. Thus I can say that if B
    is WLS, B stub talks with container B using T3, unless I made a special
    thing to force it to use RMI-IIOP.
    Forgive me if my questions are a bit confused, but I desperately want to
    know if and how it is possible to make two beans interoperate between
    different containers. And as per the EJB 2 spec, RMI-IIOP seems to bethe
    >
    Of course. This has been demonstrated at the last JavaOne.Unfortunately I was not at the last JavaOne. What was the config for the
    demo ? What containers ?
    Actually I find it quite frustrating not to be able to find any page showing
    a kind of step by step procedure to make two containers work together. Do
    you know of any such a page ?
    Thanks for your support.
    Sylvain

  • How to implement transactions in Tomcat using MySQL

    Hi,
    I am trying to find a way to implement Transactions in Tomcat 4112 using a DBCP connection pool with MySQL (connector/j 3.0.16).
    I am developing a web app using the Struts framework and have tried using JOTM for the transaction implementation. However the JOTM PreparedStatement objects do not support the getGeneratedKeys() method (which i definitely need!!!).
    I have one database with multiple datasources, but the dataase may become much larger and require multiple instances in the future so i want a solution that will scale.
    Can i use the simple JDBC connection.commit() methods? Are these robust? Or is there a simple way to use the base JTA/JTS implementation myself??
    Or is there something like JOTM that implements the full JDBC 3.0 interfaces!!
    lots of questions - sorry...
    thanks
    will crick

    I've got the same problem here.
    I want to implement a HyperlinkListener to a JLabel. (Unlike suggested above, it is only supported by JEditorPane and not JLabel)
    The goal is, that if a user clicks on a Link in a JLabel, the standard browser opens and displays that page.
    Can somebody please help?
    My ultimate goal would be to also be able to add clickable HyperLinks in ToolTip texts, but i guess that'd be even more complicated.

  • Can't update while select is active in read-committed mode- Pls Help Me

    Hi
    This is my business logic:
    I m selecting the values from three tables by UNION ALL and i m geting the record set in while loop at the same time i try to insert the values which is getting from select statement in the First Table in the same while loop.
    my problem is when i try to insert into the same table the following error is occured
    Thanks
    Merlina

    depending on how many values you have, you could store the results in memory, a vector or similar collection.
    Then close the select statement, and insert the values from your vector into the table.... should work then.
    Or, there may be a way of creating an updatable resultset ?
    This question is better directed at the
    "Java Database Connectivity (JDBC) & Transactions (JTA/JTS)" section of the forum. Maybe post a questions there, ensuring you give the URL of this question here too to avoid cross-posting.
    regards,
    Owen

  • Can't update while select is active in read-committed mode

    Hi
    This is my business logic:
    I m selecting the values from three tables by UNION ALL and i m geting the record set in while loop at the same time i try to insert the values which is getting from select statement in the First Table in the same while loop.
    my problem is when i try to insert into the same table the following error is occured
    "can't update while select is active in read-committed mode"
    Now what can i do ? please give me ur solution ...
    Thankx
    Merlina

    depending on how many values you have, you could store the results in memory, a vector or similar collection.
    Then close the select statement, and insert the values from your vector into the table.... should work then.
    Or, there may be a way of creating an updatable resultset ?
    This question is better directed at the
    "Java Database Connectivity (JDBC) & Transactions (JTA/JTS)" section of the forum. Maybe post a questions there, ensuring you give the URL of this question here too to avoid cross-posting.
    regards,
    Owen

  • Help me to control the transactions from jsp to java bean

    Please anyone can guide me how to control the transactions from jsp to java bean. I am using the Websphere studio 5.1 to develop the database application. I would like to know two method to handle the database. First, I would like to know how I can control the transactions from jsp by using java bean which is auto generated for SQL statement to connect to the database. Following code are jsp and java bean.....
    // call java bean from jsp
    for (i=0;i<10;i++)
    addCourse.execute(yr,sem,stdid,course,sec);
    I write this loop in jsp to call java bean..
    here is java bean for AddCourse.java
    package com.abac.preregist.courseoperation;
    import java.sql.*;
    import com.ibm.db.beans.*;
    * This class sets the DBModify property values. It also provides
    * methods that execute your SQL statement and return
    * a DBModify reference.
    * Generated: Sep 7, 2005 3:10:24 PM
    public class AddCourse {
         private DBModify modify;
         * Constructor for a DBModify class.
         public AddCourse() {
              super();
              initializer();
         * Creates a DBModify instance and initializes its properties.
         protected void initializer() {
              modify = new DBModify();
              try {
                   modify.setDataSourceName("jdbc/ABAC/PreRegist/PRERMIS");
                   modify.setCommand(
                        "INSERT INTO informix.javacourseouttemp " +
                        "( yr, sem, studentid, courseid, section ) " +
                        "VALUES ( :yr, :sem, :studentid, :courseid, :section )");
                   DBParameterMetaData parmMetaData = modify.getParameterMetaData();
                   parmMetaData.setParameter(
                        1,
                        "yr",
                        java.sql.DatabaseMetaData.procedureColumnIn,
                        java.sql.Types.SMALLINT,
                        Short.class);
                   parmMetaData.setParameter(
                        2,
                        "sem",
                        java.sql.DatabaseMetaData.procedureColumnIn,
                        java.sql.Types.SMALLINT,
                        Short.class);
                   parmMetaData.setParameter(
                        3,
                        "studentid",
                        java.sql.DatabaseMetaData.procedureColumnIn,
                        java.sql.Types.CHAR,
                        String.class);
                   parmMetaData.setParameter(
                        4,
                        "courseid",
                        java.sql.DatabaseMetaData.procedureColumnIn,
                        java.sql.Types.CHAR,
                        String.class);
                   parmMetaData.setParameter(
                        5,
                        "section",
                        java.sql.DatabaseMetaData.procedureColumnIn,
                        java.sql.Types.SMALLINT,
                        Short.class);
              } catch (SQLException ex) {
                   ex.printStackTrace();
         * Executes the SQL statement.
         public void execute(
              String userid,
              String password,
              Short yr,
              Short sem,
              String studentid,
              String courseid,
              Short section)
              throws SQLException {
              try {
                   modify.setUsername(userid);
                   modify.setPassword(password);
                   modify.setParameter("yr", yr);
                   modify.setParameter("sem", sem);
                   modify.setParameter("studentid", studentid);
                   modify.setParameter("courseid", courseid);
                   modify.setParameter("section", section);
                   modify.execute();
              // Free resources of modify object.
              finally {
                   modify.close();
         public void execute(
                   Short yr,
                   Short sem,
                   String studentid,
                   String courseid,
                   Short section)
                   throws SQLException {
                   try {
                        //modify.setUsername(userid);
                        //modify.setPassword(password);
                        modify.setParameter("yr", yr);
                        modify.setParameter("sem", sem);
                        modify.setParameter("studentid", studentid);
                        modify.setParameter("courseid", courseid);
                        modify.setParameter("section", section);
                        modify.execute();
                   // Free resources of modify object.
                   finally {
                        modify.close();
         * Returns a DBModify reference.
         public DBModify getDBModify() {
              return modify;
    I would like to know that how can I do for autocommit from jsp. For example, the looping is 10 times which mean I will add 10 records to the db. If the last record is failed to add to db, "how can I rollback the perivious records?" or guide me to set the commit function to handle that case. Thanks a lot for take your time to read my question.

    Hello.
    The best method is using a session bean and container managed transactions. Other method is using sessions bean and the user transaction object (JTA-JTS).
    so, JDBC has transaction management too.
    good luck.

  • Toplink distributed transaction support?

    I have a database in SQL Server and one in DB2 on the AS/400 and need to update tables in both places and commit the entire transaction.
    Can Toplink handle a distributed transaction?

    Yes, provided your J2EE container provides the necessary JTA/JTS support. TopLink can be registered with the transaction controller and thus issue and commit its SQL as part of the JTA callbacks.
    http://download-east.oracle.com/docs/cd/A97688_12/toplink.903/b10064/enterpri.htm#1020862
    If you are mapping both schemas to an object model using TopLink you may also want to look at TopLink's session broker functionality.
    http://download-east.oracle.com/docs/cd/A97688_12/toplink.903/b10064/enterpri.htm#1020687
    Doug

Maybe you are looking for