Bug #32101 com.mysql.jdbc.jdbc2.optional.ConnectionWrapper returns null in prepareStatement
Submitted: 5 Nov 2007 11:21 Modified: 3 Dec 2007 7:21
Reporter: Alex DeNeui Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.5 OS:Any
Assigned to: CPU Architecture:Any

[5 Nov 2007 11:21] Alex DeNeui
Description:
Three of the prepareStatement method overloads in ConnectionWrapper fail to return the value from PreparedStatementWrapper.getInstance().  Instead, they fall through and return the "unreachable" return null;

On line 729:

	public java.sql.PreparedStatement prepareStatement(String arg0, int arg1)
			throws SQLException {
		checkClosed();

		try {
			PreparedStatementWrapper.getInstance(this, this.mpc, this.mc
					.prepareStatement(arg0, arg1));
		} catch (SQLException sqlException) {
			checkAndFireConnectionError(sqlException);
		}

		return null; // we don't reach this code, compiler can't tell
	}

How to repeat:
1) Install 5.1.5 of Connector/J
2) Call connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)
3) Result is null

Suggested fix:
Add a "return"
[16 Nov 2007 13:37] Hasan Ceylan
Hello,

First of all, I think any bug report with pointing where the problem is deserves a prompt response to the reporter. IMHO, if a SW vendor leaves a bug report alone for over 10 days especially when it is blocker and the solution is obvious, then that vendor start to loose community support as people value their inputs being reviewed.

Now, 

I think this bug is a major major problem that makes the connector completely unusable.

I tried to get the source, make the correction and compile it for myself.

Source does not compile as well.

I kindly ask someone from MYSQL please get down on the issue and solve it ASAP as it is a plainer blocker for thousands of Connector-J users.

Regards,
Hasan Ceylan
[16 Nov 2007 13:39] Hasan Ceylan
just for the record:

Same problem exists in all the prepareStatement methods...
[16 Nov 2007 15:24] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37954
[16 Nov 2007 15:35] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37957
[17 Nov 2007 3:35] Hasan Ceylan
Thanks for the response.

The solutions is obvious. I already had a corrected version of source myself. But it does not compile. Some interface methods are not implemented in a number of places.

I opened up a different bug for that - http://bugs.mysql.com/bug.php?id=32466 .

What's the plan for the next release? If it is not soon, what is the way to get connector-j to copile,

Regards,

Hasan Ceylan
[17 Nov 2007 4:30] Mark Matthews
Because Connector/J 5.1 implements both JDBC-3 and JDBC-4 in the same driver, it can not be compiled with JDK6 alone. You need to use JDK-1.4.2 or JDK-1.5 in your JAVA_HOME, and point to your JDK6 javac binary, and JDK6 rt.jar using the "com.mysql.jdbc.java6.javac" and "com.mysql.jdbc.java6.rtjar" properties, respectively.

This information is near the top of build.xml and is also in the CHANGES file and the CHANGELOG in the online manual.

Bug#32466 has been marked as "not a bug", since the required steps are documented in files that are pointed out in the documentation as something one should read when upgrading.
[17 Nov 2007 4:32] Mark Matthews
Once Connector/J has reached GA status, we generally try and release every other month or so, depending on bug inflow. Currently there are only three bugs fixed in the 5.1 branch, so it will probably be early December before a release is cut.

You can always download snapshot builds at http://downloads.mysql.com/snapshots.php#connector-j

These are built nightly at 00:00 GMT.
[17 Nov 2007 4:42] Hasan Ceylan
Once again thanks for helping out Mark...

Regards,
Hasan Ceylan
[17 Nov 2007 5:15] Hasan Ceylan
One thing to clarify:

CHANGE, change.log etc files are for the *one*s who are upgrading. I am not upgrading. My source is compliant with JDBC and and connector-J 5.1.5 and started the my project with this version and blocked by a bug.

I *did* read the README, README.txt, doc/README doc/README.txt (which the latters are the same files),  

The generally accepted rule is the compiler instructors (be it Makefile, build.xml, etc) should make necessary checks for the building environment and report unmet criterias before going ahead and trying to compile. AutoMake is superb in that, and ant still has room for improvement.

And also sources in general include a file called BUILDING, BUILD etc. or similar file if the information is not included in README.

Build instructions in build files (Makefile, build.xml) are for developers of the files itselves, not for the audience.

If these are not met, like in this incident, the developer looks bad.

And the last thing, what I learned from the open source community ethic is, instead of trying to point fingers on people, developers should try to read between the lines of comments to find more areas to improve.

and IMHO, if the person I am dealing with is a valuable contributer and event someone who holds 30+ paid licenses, submitting patches, then I would think twice before posting...

Regards,

Hasan Ceylan
[17 Nov 2007 17:45] Mark Matthews
Hasan,

I didn't consider my reply as pointing fingers. I simply stated what one needed to do, and that in general, people should read the CHANGES file. Perhaps I made in error in saying upgraders, since really, anyone should be aware of changes made that might affect their application, so *everyone* should take a look at the changelog before using a piece of open source software.

I agree that we could do better checks of the build environment. As you state, Ant doesn't make that possible in some cases either. We'll see what we can do to fix that, but in general the capabilities are pretty weak.

I've set this bug to "documenting", as the documentation team should make the required components for building part of the manual.

Thanks for using MySQL.
[17 Nov 2007 18:57] Hasan Ceylan
Thanks for clarifications...
[19 Nov 2007 0:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38019
[19 Nov 2007 2:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38024
[3 Dec 2007 7:21] MC Brown
A note has been added to the 5.1.6 changelog: 

When using a connection from ConnectionPoolDataSource, some Connection.prepareStatement() methods would return null instead of the prepared statement.