MyISAM tables are non transactional, so I would think that even though
you can turn off the auto commit mysql will ignore it and insert the
records when you execute the statement.
On 9/3/07, Alessandro Ferrucci <[EMAIL PROTECTED]> wrote:
> the auto-commit setter executes fine with no exceptions, even introspecting
> the connection object through eclipse debugger shows me the auto-commit
> attribute is set to false.
>
> alessandro ferrucci :)
>
> On 9/3/07, James Carman <[EMAIL PROTECTED]> wrote:
> >
> > You are essentially throwing away the exception from the driver if it
> > can't set autocommit to false. I'm pretty sure that the MySQL jdbc
> > driver supports that, but you might want to print something in that
> > catch statement to make sure.
> >
> > On 9/3/07, Alessandro Ferrucci <[EMAIL PROTECTED]> wrote:
> > > also I've been stepping through this code in the debugger and right
> > after
> > > the first execute statement I still should not see anything in the DB
> > (not
> > > until I do a commit). But when I step through the first execute and I
> > check
> > > my DB I see the record has been written...I dont get that
> > >
> > > alessandro ferrucci
> > >
> > > On 9/3/07, Alessandro Ferrucci <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Yes I delete all data from it all the time.
> > > >
> > > > alessandro ferrucci
> > > >
> > > > On 9/3/07, ben short <[EMAIL PROTECTED] > wrote:
> > > > >
> > > > > Are you sure that the table is empty before you run the test?
> > > > >
> > > > > On 9/3/07, Alessandro Ferrucci < [EMAIL PROTECTED]>
> > wrote:
> > > > > > Hi this question is related to DBCP, but I will provide a sample
> > > > > without
> > > > > > DBCP code since I see the same behavior either way.
> > > > > >
> > > > > > I have this very simple class:
> > > > > >
> > > > > > for some reaosn when I debug it in eclipse, and I step through the
> > > > > first
> > > > > > statement I see the record has already been inserted in teh DB
> > when I
> > > > > put
> > > > > > autocommit to false...why is this? Also what should happen in
> > this
> > > > > case is
> > > > > > that the second statement is invalid so it throws an exception and
> > the
> > > > > > connection should rollback both statements but it is not...the
> > first
> > > > > > statement is obviously automatically commited...I cannot find out
> > why
> > > > > this
> > > > > > is not working
> > > > > >
> > > > > > thx
> > > > > >
> > > > > > alessandro ferrucci :)
> > > > > >
> > > > > > import java.sql.Connection;
> > > > > > import java.sql.DriverManager;
> > > > > > import java.sql.SQLException;
> > > > > > import java.sql.Statement;
> > > > > >
> > > > > > import org.junit.Test;
> > > > > >
> > > > > > //
> > > > > >
> > > > >
> > ****************************************************************************
> > > > >
> > > > > >
> > > > > > public class TestJDBC
> > > > > > {
> > > > > > @Test
> > > > > > public void test()
> > > > > > {
> > > > > > Connection conn = null;
> > > > > > try
> > > > > > {
> > > > > > Class.forName ("com.mysql.jdbc.Driver");
> > > > > > }
> > > > > > catch (ClassNotFoundException ex)
> > > > > > {
> > > > > > System.out.println(ex.getMessage());
> > > > > > }
> > > > > > try
> > > > > > {
> > > > > > conn = DriverManager
> > > > > >
> > > > > >
> > > > >
> > .getConnection("jdbc:mysql://localhost:3306/photos?user=root&password=");
> > > > > > conn.setAutoCommit(false);
> > > > > > }
> > > > > > catch (SQLException ex)
> > > > > > {
> > > > > >
> > > > > > }
> > > > > > Statement stmt = null;
> > > > > > try
> > > > > > {
> > > > > > stmt = conn.createStatement();
> > > > > > }
> > > > > > catch (Exception ex)
> > > > > > {
> > > > > > System.out.println(ex.getMessage());
> > > > > > }
> > > > > > try
> > > > > > {
> > > > > > stmt.execute("insert INTO photostest (id) VALUES
> > (100)");
> > > > > > stmt = conn.createStatement();
> > > > > > stmt.execute("insert INTO photostest (id2) VALUES
> > (200)");
> > > > > > }
> > > > > > catch (Exception ex)
> > > > > > {
> > > > > > System.out.println(ex.getMessage());
> > > > > > try
> > > > > > {
> > > > > > conn.rollback();
> > > > > > }
> > > > > > catch (Exception e)
> > > > > > {
> > > > > > System.out.println(ex.getMessage());
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > >
> > > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]