Transactions with Java and mySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Slav

    #1

    Transactions with Java and mySQL

    Hello,

    I'm trying to port the use of postgresql db to mysql. I'm using
    Java and having the following problem - I can't seem to write more
    than 1 query per execution. Easier to explain with an example that
    worked under postgresql and does not using mysql:

    aStatement.exec uteQuery("BEGIN ; DELETE FROM table1; DELETE FROM
    table1; DELETE FROM table3; COMMIT;");

    If I separate this into 5 different queries it works fine... Any
    ideas?? Thanks,

    Slawek
  • sdfgsd

    #2
    Re: Transactions with Java and mySQL

    > I'm trying to port the use of postgresql db to mysql. I'm using[color=blue]
    > Java and having the following problem - I can't seem to write more
    > than 1 query per execution. Easier to explain with an example that
    > worked under postgresql and does not using mysql:
    >
    > aStatement.exec uteQuery("BEGIN ; DELETE FROM table1; DELETE FROM
    > table1; DELETE FROM table3; COMMIT;");
    >
    > If I separate this into 5 different queries it works fine... Any
    > ideas?? Thanks,[/color]

    You may want to go to www.mysql.com and read up on the different table types
    in the version of mysql you are using. It is probable that your version and
    table type will not allow you to group your statements as a transaction.


    Comment

    • sdfgsd

      #3
      Re: Transactions with Java and mySQL

      > I'm trying to port the use of postgresql db to mysql. I'm using[color=blue]
      > Java and having the following problem - I can't seem to write more
      > than 1 query per execution. Easier to explain with an example that
      > worked under postgresql and does not using mysql:
      >
      > aStatement.exec uteQuery("BEGIN ; DELETE FROM table1; DELETE FROM
      > table1; DELETE FROM table3; COMMIT;");
      >
      > If I separate this into 5 different queries it works fine... Any
      > ideas?? Thanks,[/color]

      You may want to go to www.mysql.com and read up on the different table types
      in the version of mysql you are using. It is probable that your version and
      table type will not allow you to group your statements as a transaction.


      Comment

      • Slav

        #4
        Re: Transactions with Java and mySQL

        "sdfgsd" <sdfg@sdg.com > wrote in message news:<nR2jb.108 935$eS5.10815@t wister.tampabay .rr.com>...[color=blue][color=green]
        > > I'm trying to port the use of postgresql db to mysql. I'm using
        > > Java and having the following problem - I can't seem to write more
        > > than 1 query per execution. Easier to explain with an example that
        > > worked under postgresql and does not using mysql:
        > >
        > > aStatement.exec uteQuery("BEGIN ; DELETE FROM table1; DELETE FROM
        > > table1; DELETE FROM table3; COMMIT;");
        > >
        > > If I separate this into 5 different queries it works fine... Any
        > > ideas?? Thanks,[/color]
        >
        > You may want to go to www.mysql.com and read up on the different table types
        > in the version of mysql you are using. It is probable that your version and
        > table type will not allow you to group your statements as a transaction.[/color]

        Hi, I've read the mySQL docs regarding table types and it is still
        unclear to me if the problem I'm having is to do with table types (and
        you were right I use the default table type which does not support
        transactions) or with jdbc. As you can see my query, I'm performing
        operations on 3 different tables and not on the same one. Therefore
        my question is more along on the lines: is there a setting in mySQL
        that allows multiple queries at a time? The error I'm getting
        indicates an SQL error after the first ";". Thanks.

        Comment

        • Slav

          #5
          Re: Transactions with Java and mySQL

          "sdfgsd" <sdfg@sdg.com > wrote in message news:<nR2jb.108 935$eS5.10815@t wister.tampabay .rr.com>...[color=blue][color=green]
          > > I'm trying to port the use of postgresql db to mysql. I'm using
          > > Java and having the following problem - I can't seem to write more
          > > than 1 query per execution. Easier to explain with an example that
          > > worked under postgresql and does not using mysql:
          > >
          > > aStatement.exec uteQuery("BEGIN ; DELETE FROM table1; DELETE FROM
          > > table1; DELETE FROM table3; COMMIT;");
          > >
          > > If I separate this into 5 different queries it works fine... Any
          > > ideas?? Thanks,[/color]
          >
          > You may want to go to www.mysql.com and read up on the different table types
          > in the version of mysql you are using. It is probable that your version and
          > table type will not allow you to group your statements as a transaction.[/color]

          Hi, I've read the mySQL docs regarding table types and it is still
          unclear to me if the problem I'm having is to do with table types (and
          you were right I use the default table type which does not support
          transactions) or with jdbc. As you can see my query, I'm performing
          operations on 3 different tables and not on the same one. Therefore
          my question is more along on the lines: is there a setting in mySQL
          that allows multiple queries at a time? The error I'm getting
          indicates an SQL error after the first ";". Thanks.

          Comment

          • sdfgsd

            #6
            Re: Transactions with Java and mySQL


            "Slav" <slawek_jarosz@ engineer.com> wrote in message
            news:2f67c07d.0 310150936.62e96 3f7@posting.goo gle.com...[color=blue]
            > "sdfgsd" <sdfg@sdg.com > wrote in message[/color]
            news:<nR2jb.108 935$eS5.10815@t wister.tampabay .rr.com>...[color=blue][color=green][color=darkred]
            > > > I'm trying to port the use of postgresql db to mysql. I'm using
            > > > Java and having the following problem - I can't seem to write more
            > > > than 1 query per execution. Easier to explain with an example that
            > > > worked under postgresql and does not using mysql:
            > > >
            > > > aStatement.exec uteQuery("BEGIN ; DELETE FROM table1; DELETE FROM
            > > > table1; DELETE FROM table3; COMMIT;");
            > > >
            > > > If I separate this into 5 different queries it works fine... Any
            > > > ideas?? Thanks,[/color]
            > >
            > > You may want to go to www.mysql.com and read up on the different table[/color][/color]
            types[color=blue][color=green]
            > > in the version of mysql you are using. It is probable that your version[/color][/color]
            and[color=blue][color=green]
            > > table type will not allow you to group your statements as a transaction.[/color]
            >
            > Hi, I've read the mySQL docs regarding table types and it is still
            > unclear to me if the problem I'm having is to do with table types (and
            > you were right I use the default table type which does not support
            > transactions) or with jdbc. As you can see my query, I'm performing
            > operations on 3 different tables and not on the same one. Therefore
            > my question is more along on the lines: is there a setting in mySQL
            > that allows multiple queries at a time? The error I'm getting
            > indicates an SQL error after the first ";". Thanks.
            >[/color]

            Ok. I don't think there's a special setting per se. I'm not sure about the
            mysql> command line, but I run multiple queries programatically and from
            within a .sql file all the time. HTH.


            Comment

            • sdfgsd

              #7
              Re: Transactions with Java and mySQL


              "Slav" <slawek_jarosz@ engineer.com> wrote in message
              news:2f67c07d.0 310150936.62e96 3f7@posting.goo gle.com...[color=blue]
              > "sdfgsd" <sdfg@sdg.com > wrote in message[/color]
              news:<nR2jb.108 935$eS5.10815@t wister.tampabay .rr.com>...[color=blue][color=green][color=darkred]
              > > > I'm trying to port the use of postgresql db to mysql. I'm using
              > > > Java and having the following problem - I can't seem to write more
              > > > than 1 query per execution. Easier to explain with an example that
              > > > worked under postgresql and does not using mysql:
              > > >
              > > > aStatement.exec uteQuery("BEGIN ; DELETE FROM table1; DELETE FROM
              > > > table1; DELETE FROM table3; COMMIT;");
              > > >
              > > > If I separate this into 5 different queries it works fine... Any
              > > > ideas?? Thanks,[/color]
              > >
              > > You may want to go to www.mysql.com and read up on the different table[/color][/color]
              types[color=blue][color=green]
              > > in the version of mysql you are using. It is probable that your version[/color][/color]
              and[color=blue][color=green]
              > > table type will not allow you to group your statements as a transaction.[/color]
              >
              > Hi, I've read the mySQL docs regarding table types and it is still
              > unclear to me if the problem I'm having is to do with table types (and
              > you were right I use the default table type which does not support
              > transactions) or with jdbc. As you can see my query, I'm performing
              > operations on 3 different tables and not on the same one. Therefore
              > my question is more along on the lines: is there a setting in mySQL
              > that allows multiple queries at a time? The error I'm getting
              > indicates an SQL error after the first ";". Thanks.
              >[/color]

              Ok. I don't think there's a special setting per se. I'm not sure about the
              mysql> command line, but I run multiple queries programatically and from
              within a .sql file all the time. HTH.


              Comment

              Working...