I have developed a Java project that uses an SQL Server 2008 Database. Now if I want to deliver this Java application to any person such as client that will practically implement my Java application into his/her use, how will I deliver the database that is used to store the data used by the application? i-e I need to deliver the database with jar file.
If I understand correctly, you're asking how to package an MS SQLServer database in a java jar file?
That's just not possible, sorry. SQLServer is a commercial, platform-specific (Windows), native application, so the will have to be installed by the 'client'.
If you really need to embed the database in your application, and don't absolutely need to use SQL Server, there are several Java-based, embeddable databases available, such as HSQLDB, H2, Derby, SQLite, etc.
Related
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 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.
I have prepared an application that is a small demo of Student information manipulation. I have stored information related to students in a MySQL DB. Now my application is working 100% on my computer. But I want that work everywhere without depending on Database! I mean I just want "WHEREVER MY .JAR FILE GOES, DATABASE SHOULD ALSO GO ALONG WITH THAT INSIDE .JAR FILE "
So anyone who is using my application or trying it, they can realize exact result of this application.
How can I make this possible? Please someone help me.
For that I have done the following things:
I have installed MySQL database on my computer.
I have created a database on that MySQL server
I have created some tables in the database with a lots of data.. this data is to be used in my whole application, even for login.
Now I want to deliver this application to various clients but my clients are not technical persons and I don't want to give instructions to each of my client to do the above four steps.
How can I integrate some functionality into my app so that they can use my database, Tables and Data automatically .
It would be much better if the code can install the MySQL database automatically from the setup file attached with the application.
How the applications available in the market manage information
Have you thought of using another database engine?
MySQL requires the server to be installed and configured, and it is a huge task to be done by an automatic installer.
What about using for example SQLite http://www.sqlite.org/ or Apache Derby http://db.apache.org/derby/. Both of them work by creating a file in your working dir, you could setup the database and populate data at install time
I have two suggestions for you:
A. Use SQLite instead of MySQL. SQLite is an embeddable database engine and does exactly what you need. You can simply copy the .sqlite file where all the information is stored and distribute it with your JAR file. Given that you've already written you app to use MySQL, this could mean making a few changes to your code.
There is a good SQLite jdbc driver at:
https://bitbucket.org/xerial/sqlite-jdbc
I've used it before, though not extensively.
B. Use a portable installation of MySQL. If you are using Windows these are available on the MYSQL page, look for the downloads marked "ZIP Archive" instead of "MSI Installer". These versions are portable in that they do not require an installation process, just unzip the file, and start the service. Your clients need to know how to start it up, of course. Perhaps you could create a shortcut for that.
Of course, the idea of MySQL being a network server is so that everyone in the enterprise works with the same data, by connecting to the same server. If your clients will use this application in various computers in the same company, you should consider having a single MySQL Server installed, and making the clients connect to that.
Hope this helps!
Is there a database that can be embedded in a Java program but also allow access through ODBC; more specifically, ODBC through ADOdb?
The environment is MS Windows (XP on).
The situation is that a Java program (mine) runs an external program (not mine) that uses an ADOdb.Connection object to connect to the embedded database and extract data. Oh, legacy support.
I've been trying to set this up using Derby (i.e. JavaDB/Cloudscape) and the NetworkServerControl object, but cannot figure out how to configure the System DSN such that an ADODB.Connection object can connect. Chances are I'm doing it wrong, but I can't figure out how to specify the path to the Derby files.
Is there an embedded db that can be accessed in this manner? Preferably one (unlike Derby) that doesn't require unsupported third-party drivers for ODBC access?
Alternatively, am I going about this completely wrong? I'm not very conversant with databases, nor ADOdb or .NET in general.
H2 stated a ODBC driver on the features list (but still experimental).
Is it possible to have a embedded database in a small web application? What I need is there should not be any need to install any database in the server machine. By just adding a jar in the folder the database should work.
I am using Java EE, and Netbeans as my IDE. If its possible, what are the open source databases that can be embedded.
Any pointers to some good tutorials will be more helpfull.
HSQLDB, a popular embedded database, is just one jar file that you can drop in your application.
SQLite is the big one. MySQL has an embedded server, but you need to purchase a commercial license for it. Firebird also has an embedded server which it's free.
I haven't tried that but thinking about it, I think you can. I have worked with HSQLDB before and all I had to do was to run the embedded db and then run my client. You can do this by creating a cmd script in Windows or .sh script in Linux.
Some embedded databases:
H2
HSQLDB
Java DB