简体   繁体   中英

Java, compile a program with embedded derby database

I'm having trouble compiling a java program that uses an embedded Derby database. I'm using Netbeans, and used the "Clean and build" option, which created a dist folder. I added the database to the dist/resources folder, the one I have the derby connection pointed to:

System.setPropert("derby.system.home", System.getProperty("user.dir") + "//resources"

The trouble is, some people can't run the program. For some, it's as easy as clicking on the .jar file in the dist folder. For others, it won't run at all. Also, I've given people the whole package, and they have trouble running it from Netbeans with the following error:

-do-compile: [javac] Compiling 11 source files to /home/bull/Desktop/asdfasd/build/classes [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [copy] Copying 81 files to /home/bull/Desktop/asdfasd/build/classes [copy] Copied 4 empty directories to 1 empty directory under /home/bull/Desktop/asdfasd/build/classes

-post-compile:

compile:

run: [java] java.sql.SQLException: No suitable driver found for jdbc:derby:CS242 [java] Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException [java] at customeremailmanager.CustomerDB.getCustomers(CustomerDB.java:105) [java] at customeremailmanager.CustomerEmailFrame.(CustomerEmailFrame.java:26) [java] at customeremailmanager.CustomerEmailFrame$11.run(CustomerEmailFrame.java:450) [java] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251) [java] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721) [java] at java.awt.EventQueue.access$200(EventQueue.java:103) [java] at java.awt.EventQueue$3.run(EventQueue.java:682) [java] at java.awt.EventQueue$3.run(EventQueue.java:680) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) [java] at java.awt.EventQueue.dispatchEvent(EventQueue.java:691) [java] at java.awt.EventDispatchThread.pumpOneEventFo rFilters(EventDispatchThread.java:244) [java] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163) [java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) [java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147) [java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139) [java] at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

So what might I be doing wrong with this program? Here is the entire package: http://wikisend.com/download/969374/CustomerEmailManagerGUI.zip

The message "No suitable driver found for jdbc:derby:" generally means that the derby.jar file was not found in the CLASSPATH.

Are you re-distributing the derby.jar file as part of your application? If so, perhaps that process isn't properly arranging for the jar to be in your application's CLASSPATH.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM