Thursday, August 20, 2009

Jboss JDBC Driver Loading Issue

If we configure data source throug *-ds.xml (e.g. mysql-ds.xml) file in Jboss and the corresponding JDBC driver jar is only available in a WEB-INF/lib folder of an application, even though the same application tries to get a connection through configured data source, first time it will throw an ClassNotFoundException. As the class would not have loaded until the first call.

But if we try to get connection second time it will work with out any exception. This problem can be rectifed by keeping the copy of the JDBC driver jar in /server//lib folder (e.g. c:\jboss 4.0.2 \server\default\lib). This will ensure that the driver jar will be loaded in to ClassLoader at the time of server starting.

Monday, August 17, 2009

Incorrect arguments to mysql_stmt_execute

When we use MySQL connector mysql-connector-java-5.0.4-bin.jar with PreparedStatement contains more number of columns we may get the following Exception
java.sql.SQLException: Incorrect arguments to mysql_stmt_execute
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)

To fix this issue we have to use mysql-connector-java-5.1.8-bin.jar