Hello Java forum members !
Firstly please forgive my ignorance , I am beginner in java database programming.
I cannot make connection to Embedded derby database. This is what I did
1)created derby database with one table using netbeans 7.1.2. And inserted some data in that table via sql command
Now I want to read data from this database's table from a java class but I am getting this message when I run
Errorjava.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
here is my code of the class
package mypackage; import java.sql.*; public class DbConnection { Connection con; Statement st; ResultSet rs; public DbConnection() { connect(); } public void connect() { try{ String driver = "jdbc:derby:fida;user=scott;password=tiger"; Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); con= DriverManager.getConnection(driver); st=con.createStatement(); String sql = "select * from APP.STUDENT"; rs = st.executeQuery(sql); while(rs.next()) { System.out.println(rs.getInt("ID")); System.out.println(rs.getString("name")); System.out.println(rs.getString("fname")); } }catch(Exception ex){ System.out.println("Error"+ex); } } public static void main (String args[]){ new DbConnection(); } }
Please help me out , and forgive my ignorance.