Bug #722 executeUpdate attempts to execute on wrong host
Submitted: 25 Jun 2003 11:52 Modified: 25 Jun 2003 12:07
Reporter: Jon Bright Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.0.8 OS:Linux (Linux 2.4)
Assigned to: CPU Architecture:Any

[25 Jun 2003 11:52] Jon Bright
Description:
We have the following code in our app:

System.out.println(hstmt.toString()+" / " + hstmt.getConnection().getMetaData().getURL() + " / " + hstmt.getConnection().getClass().getName());
hstmt.executeUpdate( delsql.toString() );

From the debug string, we get the output:

com.mysql.jdbc.Statement@168a6fe / jdbc:mysql://192.168.10.117/quotedb?autoReconnect=true&maxReconnects=100 / com.m ysql.jdbc.Connection 

But in executeUpdate, we get the following exception:

     [java] java.sql.SQLException: General error,  message from server: "Access denied for user: 'agguser@192.168.10.118' to database 'quotedb'"
     [java]     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1651)
     [java]     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:889)
     [java]     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:956)
     [java]     at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:928)
     [java]     at com.mysql.jdbc.Connection.execSQL(Connection.java:1871)
     [java]     at com.mysql.jdbc.Connection.execSQL(Connection.java:1805)
     [java]     at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1231)
     [java]     at de.xtpro.quoteserver.Historizer.run(Historizer.java:201)

Note that access has been denied to a different IP than that which appears in the URL.  Further debug output following the exception confirms that the URL hasn't changed.  This statement is also only accessed from one Thread.

192.168.10.118 is localhost (though none of our code or config refers to it by this IP address), 192.168.10.117 is another machine.

How to repeat:
This bug is only repeatable for us when executing a delete statement, but we can consistently repeat it.  The same Statement object has previously been succesfully used to execute insert statements.
[25 Jun 2003 12:07] Mark Matthews
This is not a bug. The address after the '@' is the address that the MySQL _server_ thinks the client is connecting from. You don't seem to have granted DELETE rights for this user on the particular table/database in question.
[26 Jun 2003 1:14] Jon Bright
<puts on best sheepish look>.  Thanks for your quick reply.  You are, of course, correct.  We'll go now and carefully shoot ourselves for having bothered you :-)