[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Java: derby embedded driver path, where can I find?

Posted on 2012-08-23
7
Medium Priority
?
541 Views
Last Modified: 2012-08-23
hello Experts,

my connection test is failing at the String driver, not sure what path should be specified there.... or where to find it... any ideas?

public class JavaDBDemo {
	  static Connection conn;

	  public static void main(String[] args) {
	    String driver = "org.apache.derby.jdbc.EmbeddedDriver";
	    String connectionURL = "jdbc:derby:C:\\JAVA\\firstdb";
	    String createString = "CREATE TABLE Employee (NAME VARCHAR(32) NOT NULL, ADDRESS VARCHAR(50) NOT NULL)";
	    try {
	      Class.forName(driver);
	    } catch (java.lang.ClassNotFoundException e) {
	      e.printStackTrace();
	    }
	    try {
	      conn = DriverManager.getConnection(connectionURL);
	      Statement stmt = conn.createStatement();
	      stmt.executeUpdate(createString);

	      PreparedStatement psInsert = conn.prepareStatement("insert into Employee values (?,?)");

	      psInsert.setString(1, args[0]);
	      psInsert.setString(2, args[1]);

	      psInsert.executeUpdate();

	      Statement stmt2 = conn.createStatement();
	      ResultSet rs = stmt2.executeQuery("select * from Employee");
	      int num = 0;
	      while (rs.next()) {
	        System.out.println(++num + ": Name: " + rs.getString(1) + "\n Address" + rs.getString(2));
	      }
	      rs.close();
	    } catch (Exception e) {
	      e.printStackTrace();
	    }
	  }
	}

Open in new window


error message:
java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)

In advance, thank you for your help...

Regards,
0
Comment
Question by:epifanio67
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 38326023
You need to add the driver jar to your classpath
0
 

Author Comment

by:epifanio67
ID: 38326040
Thanks CEHJ...

Add derby.jar (full path) to PATH env var?

Regards,
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38326053
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:epifanio67
ID: 38326152
Thanks CEHJ....

sorry, I still don't follow..
I know how to add a path to my PATH var....
but I don't know the name of the driver jar...

I am looking at the JDK and also downloaded derby separately but still can't find it..

see what I mean...

Regards
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 38326848
I know how to add a path to my PATH var....
You need to read the link i posted carefully. Of all the things you need to understand in Java, the classpath is probably the most fundamental and important. It CANNOT be skimped

but I don't know the name of the driver jar...

On my system, it's 'derby.jar' so search yours on

*derby*.jar
0
 

Author Closing Comment

by:epifanio67
ID: 38327342
:-)
thank you boss....

Regards,
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38327366
:)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month19 days, 18 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question