Local Java Application - Database Selection - java

I'd like to ask for your opinion on local databases for a java application i'm developing.
Its veterinary application, meaning I'll need to store Customer, Pet and Medical History details for a start. I know how to use JDBC but I've only used it online in applets.
So, I really dont know much about local solutions and how those gonna work when I'll publish the application in a .jar, so please guide me. Would MySQL still work?
Thanks!

This is fairly general question and light on details and MySQL sounds like it would work here. If this is for local-only access and a typical client-server model is not needed then I'd encourage looking into a database engine that can be loaded directly in the JVM. One of the benefits is that there is no need to install any separate database components and the JARs for the entire database engine can be packaged in your application.
Below are a few of these:
Apache Derby
HyperSQL
H2
SQLite - Some Java wrappers around the C library are available but there are not any pure Java JDBC drivers available for this that I am aware of.
I realize that it is not difficult for developers to configure MySQL for local use but it could lead to a number of support issues for end users. It may be possible to script the installation to preconfigure a large amount of it but I am not sure of the details of that and it would be an additional item for you to work out when packaging the application.
Some general questions about utilizing MySQL for this are shown below. It may very well be the best way to go but these are just some things to consider. Most of these are not really specific to the development of the application and are more on the support side of things. Utilizing a database engine noted above can eliminate all or many of these.
Will multiple computers every have to connect simultaneously to the same database?
What MySQL password do you use?
Do you recommend that end users all use the same one which may not be good security?
Or do the end users need to create one in which case you may need to deal with forgotten passwords and the end user having to configure the password in your application?
Do your end users run antivirus software that may interfere with the database connection?
What if they have another program that uses MySQL that is already using the default port?

Related

Is it possible to embed a MySQL database server into a Java servlet?

I am in a situation where I am being asked to make a single WAR file that runs Wordpress. Using Quercus, Tomcat and httpd+mod_rewrite I was able to make a WAR file containing everything except the database, which I ran externally. However, I'm not sure how I might go about removing the dependency upon an external database (and, frankly, this whole endeavor seems like a bad idea to me).
This article describes how Wordpress has been successfully deployed on the Google App Engine and hence without needing MySQL, but this was done using JPA.
Instead of embedding a MySQL instance, if I could use an external MSSQL database connection instead that would be fine too. (This is an old post, but it seems to suggest that real MySQL is the only supported database for Wordpress.) Is the most viable option to attempt to replace each MySQL call in the Wordpress source code to a MSSQL call? Is there some kind of compatibility/translation layer that I could use instead? (I saw this question, but the solution will not work in my case.)
UPDATE: I came across MySQL-JE, but it looks out of date and not quite complete enough (not sure how I would tell Quercus/PHP to communicate with it). Has anyone used it? If so, do you think it would help solve this problem?
Embedded Database
According to this chart, MySQL is not built for embedded use.
I can point you to two pure Java database engines for embedding in a Java app. Both are open-source, free of cost, and under active development. Both have a good pedigree with a long line of database development history behind them.
H2
Derby
WordPress Requires MySQL
According to this WordPress Requirements page, specifically MySQL is required. That's annoying. The main point of SQL is to avoid database-vendor lock-in.

What are the pros/cons/substitutes for using MySQL Connector/MXJ for an application

I recently made an interesting application using Play Framework and MySQL Connector/MXJ to make a completely portable web server with database, independent of any currently installed software(including Java).
I'm still new to MXJ, and the desktop application realm (as opposed to straight-up webapps), so I'm wondering if there are other, better methods for storing/accessing large amounts of data than embedded MySQL. I would assume so, since it seems not many people use MXJ. It essentially just packs mysqld.exe in its various forms for multiple operating systems and platforms. It runs in its own thread, and stores its data in whatever directory you provide.
For an application that frequently analyzes and searches through data in large chunks(100MB to 5GB), what other (fast)options are there, or am I justified in my webapp-laziness of bringing along MySQL?
Independent of any currently installed software(including Java).
If you are looking for an embedded database for a desktop application, then you can go for SQLITE. However, there are pros/cons for using either MySQL or SQLite
SQLite:
Easier to setup
Great for temporary (testing databases)
Great for rapid development
Great for embedding in an application
Doesn't have user management
Doesn't have many performance features
Doesn't scale well.
MySQL:
Far more difficult/complex to set up
Better options for performance tuning
Fit for a production database
Can scale well if tuned properly
Can manage users, permissions, etc.
You can find more info on when to use SQLite here
UPDATE: I came across HSQLDB and here are its test results. HamsterDb is another option.
Do you really need a database if your app is single user and desktop based? Maybe it is faster to simply write large files to the local filesystem then loading then through the network tier. If your app is very complex you could use an embedded db just for storing your domain and configuration, but if its not maybe you can avoid using a db + sql + o/r-mapping and so on.

Distribute Java application in Mysql

I wish to distribute my restaurant application, which uses MySQL to store the data. I plan to use Lauch4j to distribute its .exe file.
But the program also requires the user to have mysql Installed, is it possible to hard code mysql setup within the application? or anything else that could be done to avoid the user the pain of downloading and installing it?
It is a matter of opinion, but I advise you to not do it.
If your main concern is the install process being easy for the user, use some embedded DB. That way, the user not only will not have to care about things like firewalls, possible mysql vulnerabilities and so on.
If you need something that only mysql or other standalone DBs can provide you, don't hide it from the user. Technical capable users should be allowed to configure your app to run in the sql engines they already have installed (if they want to). Other people should at least know that you are installing something else apart of your app. Of course less tech-savy users will be scared, but if they do not know what they are doing they should not be tinkering with MySQL (or even installing programs).
In essence: Let the people know what you are installing in their systems. Allow them to reuse other DB engines if they chose to.
If i was you, if MySQL was the option, I would just take it for granted that it is installed and ask for the connection parameters (make it the first step of the installation procedure so you can check it before proceeding).
You can use SQLite in for your application. If any application needs to store data in the same system only and the application needs to be small and lightweight application then you can use sqlite as database. SQLite makes a great application file format.

Java application with Microsoft Access or other database?

I am studying Information Technology at a local college. I am currently doing a Java project for one of my Modules. We are expected to make a Java application that communicates with a Microsoft Access database. I am working in a group, and all of us are assigned to code separate functions of the software. However, we need to share one database. We are currently using ODBC on our individual computers and are using JDBC to connect to the database on the local machine. What we have thought is to just work on separate Microsoft Access databases and then just combine them later on. But I think that's not the best way. Is there a way that will allow me and my group members to have a centralized database, to which all of us can connect and make our queries? Is this possible by hosting the Microsoft Access database somewhere online, and then connecting to it from inside the Java software. Please help me out, as I have no idea how to get a centralized Microsoft Access database.
If you want to get rid of this by using Microsoft Access is because that's the easiest way out for you and your group to solve this kind of problem but I'd rather suggest you to use the database using a database provided by Java Derby database, it's quite help you to short your code within the server. Maybe I will suggest you to use Netbeans as a GUI and the Derby to control the database.
So what's your core problem is that a programming side or configuration and control within the hosting ? Thanks

Java DB Client-server technology - centralized DB - How?

I have a project this year. It is about developing a Java application with a database for sharing and validating documents between the manager, secretary and head of finance.
My question is: How to make the database accessible by all, since the application will be installed on computers that I mentioned above, do I have to install it (the database) on these computers? The constraints of consistency and integrity of the database will be violated. The users will not have the same copy after each update!
Is there a possibility (or technology in Java) to put the database on the web and there will be accessible by all, or make it accessible from a computer that I realize as a server (client-server).
I would be grateful for your help or giving links for Tutorials.
How to make the database accessible by all, since the application will be installed on computers that I mentioned above, do I have to install it (the database) on these computers? The constraints of consistency and integrity of the database will be violated. The users will not have the same copy after each update!
Your question suggests that you will need one database on one computer. Let's call it a DB computer. I'd suggest this be a server, that no one from regular staff, such as secretary, manager, etc... can access.
Having one central database will eliminate your worries about integrity violation.
Now, you have two options. You can make a web application that your users will use to interact with your system. This is a more modern approach, since you'll have a 3 tier system:
users will access your application via a browser
the web application itself is stored on an application server, and it is accessing the database
the database is the backend part
The second option is making a desktop application and deploying it to everybody's computer that will use it; and afterwards making it connect to the database for interacting with it.
The first option is easier when you want to expose your application to a large number of users (and to the web), but know what you're doing when doing stuff like this, since you have to take security very seriously.
If you go the first route, you will need a few things:
First, a database. Use what you can, but if you need free and high quality databases, use PostgreSQL or MySQL.
Second, an application server. I suggest using Tomcat or GlassFish.
Now, you need to develop your application using JavaEE. There is a wealth of information about this, so I hope this will help you in the beginning and point you in the right direction.
Note that Tomcat doesn't support Java EE fully, but a subset of it. And this subset is surely more than enough for what you need to accomplish.
If I understand you correctly, you are looking for ways to implement a client-server system, where several clients on distinct computers each connect to a central server (or cluster of servers) hosting a DB. In Java, usually (but not necessarily) the DB is inside a web application, and the clients are lightweight web clients - in this case it is usually called an enterprise application.
Java has a whole dedicated SDK for this, called Java Enterprise Edition. You may find many questions dealing with this on SO, here are a few which I think may be especially helpful:
Is the offical Sun Java EE tutorial the best way to learn how to make Java web apps?
What to learn for making Java web applications in Java EE 6?

Categories

Resources