在执行Testcase的时候,出现了java.sql.SQLException: Incorrect arguments to mysql_stmt_execute错误。最后查到是因为 JDBC Connection url 少加了useServerPrepStmts=false 参数,然后从网上找到 这个参数的说明:
[quote]Server-side Prepared Statements — Connector/J 3.1 will automatically detect and use server-side prepared statements when they are available (MySQL server version 4.1.0 and newer).
Starting with version 3.1.7, the driver scans SQL you are preparing via all variants of Connection.prepareStatement() to determine if it is a supported type of statement to prepare on the server side, and if it is not supported by the server, it instead prepares it as a client-side emulated prepared statement. You can disable this feature by passing emulateUnsupportedPstmts=false in your JDBC URL.
If your application encounters issues with server-side prepared statements, you can revert to the older client-side emulated prepared statement code that is still presently used for MySQL servers older than 4.1.0 with the connection property useServerPrepStmts=false
[/quote]
[quote]Server-side Prepared Statements — Connector/J 3.1 will automatically detect and use server-side prepared statements when they are available (MySQL server version 4.1.0 and newer).
Starting with version 3.1.7, the driver scans SQL you are preparing via all variants of Connection.prepareStatement() to determine if it is a supported type of statement to prepare on the server side, and if it is not supported by the server, it instead prepares it as a client-side emulated prepared statement. You can disable this feature by passing emulateUnsupportedPstmts=false in your JDBC URL.
If your application encounters issues with server-side prepared statements, you can revert to the older client-side emulated prepared statement code that is still presently used for MySQL servers older than 4.1.0 with the connection property useServerPrepStmts=false
[/quote]
本文介绍了在使用JDBC连接MySQL时遇到的java.sql.SQLException:Incorrectarguments tomysql_stmt_execute错误,并详细解释了如何通过在JDBC URL中添加useServerPrepStmts=false参数来解决这一问题。
656

被折叠的 条评论
为什么被折叠?



