import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DerbyTest {
    private Connection connect = null;
    private Statement statement = null;
    private ResultSet resultSet = null;

    public DerbyTest() throws Exception {
        try {

            Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
            connect = DriverManager.getConnection("jdbc:derby://localhost:`1527/vineet");
            statement=connect.createStatement();
                        resultSet = statement.executeQuery("SELECT * FROM EMPLOYEE");
            while (resultSet.next()) {
                String user = resultSet.getString("name");
                String number = resultSet.getString("number");
                System.out.println("User: " + user);
                System.out.println("ID: " + number);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            close();
        }

    }

    private void close() {
        try {
            if (resultSet != null) {
                resultSet.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connect != null) {
                connect.close();
            }
        } catch (Exception e) {

        }
    }

    public static void main(String[] args) throws Exception {
        DerbyTest dao = new DerbyTest();
    }

}

when the above code snippet is executed the is no class found exception.how can i connect to derby embeddeddriver? because when i create a database in netbeans the it automatically get connected to derby networkdriver or clientdriver as in the above code snippet ,so please help me out.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Add derby.jar to your project's library list. And that is as much as I will say about it as classpath discussions always become ugly on a forum. Find a tutor and/or read the IDE documentation thoroughly and read everything you can find about classpath.

i have added derby.jar in the folder list but still class not found exception.

This article has been dead for over six months. Start a new discussion instead.