Discussions

General J2EE: jdbc transactions????

  1. jdbc transactions???? (3 messages)

    I have the following problem.

    1) Query to get the total number of entries.
    2) ?
    3) Query and get rows 350,000 - 350,500 of 56,000,000 entries.

    How can I ignore a different transactions inserts/deletes at step 2?

    Threaded Messages (3)

  2. jdbc transactions????[ Go to top ]

    To count the number of entries in a table:
    select count(*) from mytable

    Add a where clause to count the number of rows in a selection:
    select count(*) from mytable where surname='Smith'

    To get a range:
    select * from mytable where myid between 350000 and 350500

    Check out this site: http://www.w3schools.com/sql/
  3. jdbc transactions????[ Go to top ]

    The usual way to do this is kind of thing is...

    Obtain connection
    Call connection.setAutoCommit(false)
    try{
       operation #1
       operation #2
       operation #3
       connection.commit();
    }
    catch{SomeSortOfException e){
       connection.rollback();
    }
    finally{
       connection.close();
    }

    Hope this makes sense.

    Bob
  4. jdbc transactions????[ Go to top ]

    Why use JDBC? In the long term of things you should really look to using a persistance layer for your application. I would recomend Hibernate because it has a low learning curve. Using regular JDBC in your application with the reall cool persistence tools out there doesn't make much sense to me.