My code works fine with autcommit on..however it does not support
autocommit off. This is quite a big bug, or I have missed something out.
Please let me know as I it would be of great interest to me if I was
mistaken or correct and you will consider fixing it.

If I switch off auto commit and select rows from a database table in a
loop when I enter new values to the table it will not find them unless I
specifically commit after every select statement. 
Surely this is select for update( with InnoDB) ? not just an ordinary
select! 

This presents awkwardness with multi-threading and I have to do
work-around such as not committing if a flag is set which should not be
necessary.
I have tried afew versions of you JDBC driver and it always performs the
same.

You should be able to make simple selects without having to commit, the
c api does exactly that!

Here is some example java code to prove point:

import java.sql.*;
import java.util.*;

public class TestSQL
{

        static Connection conn;
        public static Connection getConnection()
        {
                try
                {
                        if (conn == null)
                        {
 
Class.forName("com.mysql.jdbc.Driver").newInstance();
                              conn =
DriverManager.getConnection("jdbc:mysql://localhost/operations?user=root
&password=pineapple");
                                System.out.println("new connection
created!!");
                        }
                      conn.setAutoCommit(false);
                        return conn;
                }
                catch (Exception e)
                {
                        System.out.println ("Connect Exception"+e);
                        return null;
                }
        }

//      Main Method for Testing only 
        public static void main(String args[]) throws Exception
        {
                Connection conn=  TestSQL.getConnection();
                while(true)
                {
                        ArrayList results = new ArrayList();
                        Statement stmt = conn.createStatement();
                        //ResultSet rs = stmt.executeQuery("SELECT
feed_id from sotf_feed_event");  
                        PreparedStatement ps =
conn.prepareStatement("SELECT feed_id from sotf_feed_event");
                        ResultSet rs = ps.executeQuery();
                        ResultSetMetaData meta = rs.getMetaData();
                        int count;
       
                        count = meta.getColumnCount();
                        while (rs.next())
                        {
                                Hashtable cols= new Hashtable(count);
                                int i;
                                for (i=0;i<count;i++)
                                {
                                        Object ob = rs.getObject(i+1);
                                        if (rs.wasNull())
                                        {
                                                ob = "null";
                                        }
                                        else
                                        {
 
cols.put(meta.getColumnLabel(i+1),ob);
                                        }
                                }
                                results.add(cols);
                        }

                        if(results.size()>0)
                        {       
                                System.out.println("got something");
                        }
                        else
                        {
                                System.out.println("nothing");
                        }
                        // if I dont put this in it never finds a newly
added row
                        //conn.commit();
                        Thread.sleep(5000);
                        rs = null;
                }
        }
}

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to