Bug #8781 Prepared Statement without parameters after executing brokes connection;
Submitted: 24 Feb 2005 16:53 Modified: 24 Feb 2005 18:13
Reporter: Vadims Zemlanojs Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:4.1.1-alpha-standard OS:Windows (windows)
Assigned to: CPU Architecture:Any

[24 Feb 2005 16:53] Vadims Zemlanojs
Description:
Prepared Statement without parameters after executing brokes connection;
The next  executed Statement  in the same connection raises exception:

Access denied for user: 'test'@'192.168.5.52' to database 'TESTDB:3306'

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: Connection reset by peer: socket write error

STACKTRACE:

java.net.SocketException: Connection reset by peer: socket write error

	at java.net.SocketOutputStream.socketWrite0(Native Method)

	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)

	at java.net.SocketOutputStream.write(SocketOutputStream.java:136)

	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)

	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:124)

	at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2616)

	at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2547)

	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1512)

	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)

	at com.mysql.jdbc.Connection.execSQL(Connection.java:2376)

	at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)

	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1860)

	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1494)

	at test.Untitled1.<init>(Untitled1.java:31)

	at test.Untitled1.main(Untitled1.java:42)

** END NESTED EXCEPTION **

How to repeat:
try {
           Properties info = new Properties();
           Class.forName("com.mysql.jdbc.Driver");
           info.setProperty("user", "test");
           info.setProperty("password", "test");        
           Connection conn = DriverManager.getConnection(
                    "jdbc:mysql://192.168.5.52/TESTDB", info);
           PreparedStatement stmt;           
           stmt = conn.prepareStatement("insert into TESTDB.TEST(NOTE) values('HkhjD')");
           stmt.execute();
           stmt.close();
           stmt = conn.prepareStatement("insert into TESTDB.TEST(NOTE) values('HkhjD')");
           stmt.execute();
           stmt.close();
           conn.close();           
        } catch (Exception ex) {            
            System.out.println(ex.getMessage());            
        }

CREATE TABLE TEST(
 ID INT NOT NULL AUTO_INCREMENT,
 TP CHAR(2),
 NOTE VARCHAR(255),
 DATETIME  TIMESTAMP,
PRIMARY KEY (ID));
[24 Feb 2005 16:58] Vadims Zemlanojs
The Line"Access denied for user: 'test'@'192.168.25.2' to database 'TESTDB:3306' " - is inserted by mistake.
[24 Feb 2005 17:04] Vadims Zemlanojs
For drivers mysql-connector-java-3.1.7-bin.jar and mysql-connector-java-3.2.0-alpha-bin.jar.
In mysql-connector-java-3.0.10-stable-bin.jar and mysql-connector-java-3.1.1-alpha-bin.jar is all right.
[24 Feb 2005 18:13] Aleksey Kishkin
tested against connector/j 3.1.7 and mysql 4.1.10 on win xp sp2, didn't get any error. Could you please run your test against latest mysql version? (4.1.10 for now) , because sinse 4.1.1-alfa a lot of bugs were fixed in mysql code..