The problem: I am using DBIx::MyServer to simulate a MySQL database for a project at work. We need to be able to connect to it from Perl, Java, and C++. Perl and C++ were having no problems. Java, through JDBC, was just giving us fits. It didn't seem to be using the right protocol, which made no sense.
I know next to nothing about Java or JDBC, but as the author of our MySQL emulator, I'm the one who has to solve it. I grab a copy of the Java code from SVN and try to run it. Of course, I immediately run into problems because the classpath is completely wrong.
A few go-rounds with the Java developer and he finally gives me a line to run on my Mac. Yep, I see the problem.
This is where OSS really shines - I can go email the author of the module. He replies pretty quickly. Unfortunately, the reply is "I never tried JDBC. But, if you get me a minimal testcase, I'll take a look."
Ah-ha! The next step is to build a minimal testcase. There are several reasons CPAN authors ask for them. The first is that it gives them the ability to replicate the problem. The second is (as we're about to see) the process of generating the minimal testcase can solve the problem.
I start building the minimal testcase. The first thing was to remove all of our proprietary code. So, I created a Java class that creates a connection and reports success or failure, then exits. I also created a Perl script that creates a minimal DBIx::MyServer server (taken almost verbatim from the distro). It works.
Normally, people talk about removing stuff from the broken code till it starts workings. But, in this case, I had a working testcase, so I needed to add stuff till it breaks. I replaced the stock DBI call with the call to my emulator and it quickly broke.
I took about 20 minutes to verify that the addition of that one line was what actually caused the breakage. Most people are so quick to say "Oh, I saw it once - that must be the problem!" and I'm just as bad as anyone. That time taken to truly verify the breaking piece was critical because it gave me another lead.
After some faffing about, I learned more about how MySQL negotiates a connection that I ever wanted to know. Namely that there's two protocols that are completely and utterly incompatible. The initial problem, if you recall, was that JDBC was using the older protocol even though DBIx::MyServer was requesting the newer one. JDBC, it turned out, apparently didn't care about what flags the server would set in its handshake. Instead, it preferred to rely on an arbitrary text string that my emulator wasn't setting properly. A quick hard-code and we're good.
My JDBC connector came from MySQL itself. I'm sure they had a good reason for doing what they did, but it was certainly annoying. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Solving problems and fixing bugs
by Your Mother (Archbishop) on Mar 22, 2008 at 23:52 UTC | |
by nefigah (Monk) on Mar 23, 2008 at 08:55 UTC | |
by Your Mother (Archbishop) on Mar 27, 2008 at 15:54 UTC | |
|
Re: Solving problems and fixing bugs
by ack (Deacon) on Mar 25, 2008 at 03:51 UTC | |
|
Re: Solving problems and fixing bugs
by alpha (Scribe) on Mar 24, 2008 at 14:15 UTC | |
by dragonchild (Archbishop) on Mar 24, 2008 at 17:42 UTC |