JDBC ClassNotFoundException (NetBeans, Classpath, Java)
If you get a java.lang.ClassNotFoundException error when loading a database driver using the statement:
You can either:
Set CLASSPATH in DOS
Go into DOS (Start/Run/cmd.exe):
For example, if your jar file is at: C:/Program
set CLASSPATH=.;C:/Program Files/java/jdk1.6.0_01/lib/mysql-connector-java-5.0.6-bin.jar
That’s all. But it won’t work if you’re trying to run code in Netbeans.
Set Your Project’s Classpath in Netbeans
If you’re using netbeans, set your project’s classpath.
1. Right-click on your project.
2. Select “Properties.”
3. Click “Libraries.”
4. Click “Add JAR/Folder”
5. Choose your MYSQL driver JAR file.
HEY. Did you find this post useful as hell? I know you did. Then link to this page, Stumble it, Del.icio.us it, do whatever you can to pump this page up the Google SERPs so other people looking for this info can find it easier. Thanks.
Why This Has Anything to Do With SEO
It took me over 30 minutes to find this solution. I was this close to throwing in the towel. So once I figured out the solution, I wrote a page I wish I found at the top of Google’s search results when I looked for “jdbc classnotfoundexception.” That way, other people looking for the same information won’t be frustrated like I was. Because I’m working in a long tail space, to get this page to rank high I just optimized the content. But I didn’t keyword spam or pepper my H tags with related terms. Instead, I optimized for you.
Ok, so it’s not perfectly optimized for you if you’re an RSS subscriber of mine, since you’re interested in SEO, not Java. But if you found this page through Google, you’re thanking me now because:
- I give you exactly what you were looking for.
- I get straight to the point. Instead of starting off with a long irrelevant opening paragraph, I explain the problem and give you the answer. Instant gratification baby.
- I keep it short. I use as few words as I can to save you time.
- I keep it simple. Instead of trying to crack you up with dumb jokes or titilate you with fancy metaphors, I use simple words so even a caveman can “get it.”
Some people say ranking is about links, not content. Is it better to be tall and rich, or loyal and charismatic? Why are marketers trying to convince you its all about looks? (Yeah, just think about that for a minute :D)
Given two websites with equal visibility, the site that publishes the most compelling content will always win, showering the site with even more visibility. If marketing is all it takes, Paris Hilton would have sold more CDs.
A few articles that both helped me and frustrated me (hint: natural outbound links to relevant, authoritative pages will help you win Google’s trust):