Click here to Skip to main content
12,896,108 members (53,277 online)
Rate this:
Please Sign up or sign in to vote.
See more: Java JDBC Apache path
Hello to all,
Since I am very new to the community, I hope you will excuse my automatic question writing (can't seem to find an adequate answer).

I am learning about JDBC, and ran against a wall in start. I managed to set up an example DB, called Lesson22, and added a table Employee with 3 rows of data.
Now, in my main java project using eclipse IDE i wrote something like this:

package com.rvs.JavaI.JDBC;
import java.sql.*;
public class MainClass {
	public static void main(String argv[])
		Connection conn = null;
		Statement stmt = null;
		ResultSet  rset= null;
		try {
    conn =   DriverManager.getConnection("jdbc:derby://localhost:1527/Lesson22");
			String query = "SELECT * from Employee";
			stmt = conn.createStatement();
			rset = stmt.executeQuery(query);
				int empNo = rset.getInt("EMPNO");
				String eName = rset.getString("ENAME");
				String job = rset.getString("JOB_TITLE");
				System.out.println("" + empNo + ", " + eName + ", " + job);
		catch (SQLException se) {
			System.out.println("SQLError: " + se.getMessage() + " code: " + se.getErrorCode());
		catch(Exception e) {
		finally {
			try {
			}catch (Exception e) {

The thing is I have seen a comment on that line, and it said that I can skip this line if using Derby, but derbyclient.jar has to be included into the CLASSPATH variable.
Read it, done it, i think at least...
Commenting the line that spills the drink makes the app bust out on the last try{}catch{} block, where I attempt to free used system resources. The console output after commenting the Class.forName() line:

SQLError: No suitable driver found for jdbc:derby://localhost:1527/Lesson22 code: 0

And with the Class.forName() line:

java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
at$ Source)
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.rvs.JavaI.JDBC.MainClass.main(

Where's the catch? What did I do wrong? No doubt I messed up, but can anyone explain to me WHAT I did :)? THANKS!


Think I have somehow found out that I am missing the
this    ClassNotFoundException  (id=37)
arg0    "org.apache.derby.jdbc.EmbeddedDriver" (id=38)

Derby drivers...or am I wrong? Thank you for the answer, but's not that...:(
Posted 2-Jul-12 2:09am
Updated 2-Jul-12 9:17am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I havent given a shot but I think this is what the problem might be. You havnt specified Username and Password in connection string.
So the connection string would be something like this:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170424.1 | Last Updated 2 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100