Hi everyone! Sorry to bother, but I've searched, and attempted, and failed at setting this up, and it's kind of frustrating. Is there someone out there who might be able to tell me how to get the MySQL JDBC drivers to work? I have my classpath set to: c:\java\bin;C:\jdbc\mysql-connector-java-2.0.14-bin.jar This includes the java path, and also the path to MySQL Connector/J. I'm new to JDBC, obviously, but I keep getting the "No Suitable Driver" Exception. Any and all help is GREATLY appreciated )
If we could see your code where you are trying to establish the connection... Also, when you say that is your classpath, where did you set that classpath? At runtime? -- java -classpath.... Environment Variables?
not using Class.forName was exactly your problem. That is what actually loads the Driver for that DriverManager (among others) uses to access your Database. The Driver is what converts your JAVA instructions into instructions that a DBMS can understand. Kind of like a Gateway. Good job trouble shooting!
Joined: Dec 02, 2002
So even if you set the enviro var, you still have to load the driver with Class.forName() for the DriverManager, huh? Okay, I get it now (I think). I'll keep plugging at it, but thanks for the help! )
The classpath tells both the java compiler and the VM where to find additional API's/Libraries, whatever you want to call them. When you put your Connector/J Driver in your classpath, all that did was add another search path so that when the compiler or the VM needs these libraries, it knows where to find them. What JDBC does is use Reflection to load the Driver. That basically means that the Connector/J Driver.class file get's loaded and compiled on the fly, or at runtime instead of at compile time. I don't know why they did it this way. It's just like with the standard API set. Just because they are available via the classpath doesn't mean they are being used. So as you have probably infered, you not only need the Driver in your classpath so java can find it, but you also need to load it. In fact, you only need the Connector/J Driver in your classpath when you are executing the code, not when compiling, because it compiles the driver at runtime. However, I have it in my classpath for both compile and execution. Just in case. Here is a link to a tutorial I have started on the very basics of JDBC. I basically simplified the very simple JDBC Tutorial from Sun. But it hits on a few details that Sun thought most people would infer. I however didn't so I though I would help others like me. [ December 11, 2002: Message edited by: Gregg Bolinger ]