import java.sql.*; import java.util.*; public class TestX { static Connection getConnection() throws Exception { Connection c = DriverManager.getConnection("jdbc:mysql://gimli/test?user=test&password=test"); return c; } static int i; public static void main(String args[]) throws Exception { for(i = 0; i < 1000; ++i) { test(); } } static void test() throws Exception { Connection c2 = getConnection(); Connection c = getConnection(); c.createStatement().executeUpdate("drop table if exists test"); c.createStatement().executeUpdate("create table test(c1 varchar(10)) engine=myisam"); // insert on connection two c2.createStatement().executeUpdate("insert into test values ('aaa')"); // query from connection one ResultSet rs = c.createStatement().executeQuery("SELECT c1 FROM test"); rs.next(); String str = rs.getString(1); // exception thrown here System.out.println("Run #" + i + ", c1=" + str); rs.close(); //c.createStatement().executeUpdate("drop table if exists test"); c.close(); } }