简体   繁体   中英

Include JavaDB into .jar file (Netbeans)

I have finally finished my project - a small multiple-choice/vocabulary trainer and I'd like to use it as a standalone jar now. Problem now is: If I do start it within the build-folder (projectname/dist) everything runs fine. But when I try to run it from somewhere else I can't connect to the database anymore.

Is there a way to include the DB-files to the .jar file? Or to just copy it to the same folder? Or do I need to have JavaDB installed on the PC's I run it on?

This is the way I do connect to the db:

Class.forName("org.apache.derby.jdbc.ClientDriver");
con = DriverManager.getConnection("jdbc:derby://localhost:1527/DataBase");
stmt = con.createStatement();

So is there any chance I can create a portable app of this, which I can run eg from an usb-stick?

You do not install JavaDB. However, it will create files, if you tell it to, that hold your DB info. Look at the create=yes option on the JDBC URL. You will have to tell it where to put the files for the DB. They could be on a USB, as long as it is writable.

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