I have a database-driven application (Apache Derby). I connect to the database by a URL:
jdbc:derby://localhost:1527/kcal_calc_db
My database was created via NetBeans, and is in the '.netbeans-derby' folder. How can I include this database with my JAR/EXE file?
Try this related question: Distribute a database made with JavaDB with Java program
Note that you'll want your database to be accessed as an Embedded database, not a Client-Server database, so you'll need to change your Connection URL, use the Embedded JDBC driver, package derby.jar into your application, etc.
Related
I have a Java Spring MVC web application.
To run it, users have to install and configure a MySQL database for it to connect to (to load configuration and store user info and so on).
Is there a way to include an SQL database in the WAR file that is ready to use, so users don't have to set up the MySQL database?
You can try using SQLite by following this guide available on baeldung.
In-Memory Database like SQLite or HSQLDB or H2 should be used in case you want the data not to be persisted.
Please I intend to upload a small spring application I built to my git account. It uses tomcat server. What I don't know is that does the convention mandate that I upload my project together with the server or i upload the project alone and a person who intends to view the application downloads it and downloads his/her own server to be able to use the application? Here is an image file structure.
enter image description here
And another issue is this application makes use of a database I created using mySQL workbench. How do I now make this upload together with my database?
Basically if it is a pure Java / Spring application the one using it / downloading it must setup the application server and the database server. If you need any init scripts for your database you can add them to your project (e.g. SQL Scripts).
If you want everything to work out of the box, without requiring one to setup a database server and an application server, you should have a look at spring boot (ships with an embedded tomcat) and may use an embedded database like HSQL or SQLite.
Hope I could help
Wikipedia states that derby database can be embedded in a java application. Does it mean that we do not need to install a database server separately as if we were using Mysql for the same application?
Does it mean that we can simply ship a jar file with the database embedded in it, and not worry about installing a database server separately?
Yes you are right, Derby is a database internally supported by Java. This database can be of particular use when creating desktop applications or creating applications in which we do not want to install a database server on target machine.
Derby libraries can directly read database files that are held in JAR archives, so no need to install Database servers for this. Derby has all of the features that you would expect from a modern SQL database.
I created an mdf data base file in visual studio 2010
is there any way to connect to this data base from java netbeans project
I find a jdbc driver but it didn't work
You cannot work directly with the MDF file from Java. You will need to have a database program instance open on the MDF file, which you then can talk to through JDBC if the database program instance has a JDBC driver available.
If all you need is a simple database for your Java program, then look into Apache Derby which can be embedded in your application.
I created and deployed a javadb-powered portable swing application.
The app creates the javadb database folder as expected if it doesn't exist.
Now the time may come when I would need to browse that embedded database folder like I would using Mysql Query Browser or something. How do I do this?
Any JDBC base query tool should be able to connect to the database as long as your application is not running.
A list of tools is available in the Derby wiki:
http://wiki.apache.org/db-derby/UsesOfDerby#GUI_Tools