This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I've written a program that takes data from some xml files stored on a server and populates a database with the data. I started by developing in Eclipse 3.2.0 on Windows XP Professional using JDOM for parsing the xml and MySQL Connector/J 3.1 for database connectivity.
When installing MySQL Connector/J 3.1 the instructions (linked from dev.mysql.com, http://www.developer.com/java/data/article.php/3417381#Installation_and_Preparation_of_MySQL) mentioned three methods for using the driver. Following the tutorial, I chose the option in which the jar file named mysql-connector-java-3.0.17-ga-bin.jar is copied into the folder named C:\java\j2sdk1.4.2_12\jre\lib\ext. The tutorial claimed that this made it unnecessary to add this jar to the classpath.
I completed and tested the program in Eclipse and was satisfied with the results, so I chose to go to the next step. Using Ant I wanted to create an executable jar that will run my program. I was able to create the executable jar, but it threw the following exception:
Clearly the JDBC driver class can't be found. Assuming this was because I might have to actually add the jar file to the classpath I went ahead and edited the classpath to include C:\java\j2sdk1.4.2_12\jre\lib\ext\mysql-connector-java-3.0.17-ga-bin.jar. I rebuilt the executable jar and tried again. Same exception thrown.
I then deleted the jar file in C:\java\j2sdk1.4.2_12\jre\lib\ext\ and changed the classpath to use C:\java\mysql-connector-java-3.0.17-ga\mysql-connector-java-3.0.17-ga\mysql-connector-java-3.0.17-ga-bin.jar. I tried again and it failed again.
I returned to working in Eclipse this time without the jar in the classpath or in C:\java\j2sdk1.4.2_12\jre\lib\ext\ and of course it failed once more.
I put the jar back in C:\java\j2sdk1.4.2_12\jre\lib\ext\ and in the classpath. This time I added a line to the build file to copy the jar and paste it in the directory where my executable jar would be run from. I had done this with the JDOM jar, so I was hoping it would work in this case too. But it didn't.
At this point I am completely confused. My Google searches for solutions to this problem have turned up nothing and none of my resource books have any useful information for solving this problem. I was hoping that someone on these forums might have a suggestion for fixing this bug.
Thanks in advance for advice you are able to give me.
1. show the code that loads the driver. 2. Are you sure thats the JRE you are running your program from _within_ eclipse with? Check your launch configuration.
Joined: Feb 21, 2005
Thanks for the reply.
2. According to Eclipse, the installed JRE's are j2sdk1.4.2_12 and jre1.5.0_06. I have j2sdk1.4.2_12 checked, so it is added to the build path of newly created Java projects by default. And looking at the build path in the project properties I see that j2sdk1.4.2_12 is the JRE System Library on the libraries tab.