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

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?

Related

Creating database on client computer for java desktop application (swing)

I'm creating a java desktop application using swing which requires some database persistance for which I'm planning to use Hibernate. I'm pretty new to desktop application development so I wanted to know if and how the database can be created on the client computer when installed.
Is there a script to be run or maybe a hibernate configuration which initiates database creation?
A sample tutorial or example illustrating this will be ideal (although I was not able to find one).
Thanks in advance for any help provided.
Hibernate is not an database server itself, it is a object-relational mapping framework so you need a either embedded or stanalone database server. Java DB that comes with the JDK will be sufficent for desktop applications.
http://hamidseta.blogspot.in/2008/05/install-mysql-server-50-silently.html
In your package installer scripts perform the steps of silent MySql installation. In the BAT file put the code you find in the above link before triggering your Java application installer.
As per free licensing terms, one should not package MySql bundle for free, just check about the licensing if you bother.
I think it would be better if you can start with javaDB or SQLite.
They are perferred embedded database technologies for desktop java applications.
You can download the jar for sqlite-jdbc from here.
Take a look at few tutorials on JDBC
If you making swing applications, make sure you learn to use swing worker well. It will
be important to perform background processing.
Hibernate is Framework used as middle layer in project which interact between database and Business layer logic.
Hibernate features
J2EE integration
Object/Relational mapping
Automatic primary key generation
Object-oriented query language
So my suggestion is to go with MySQL because
Handles large databases. We use MySQL Server with databases that contain 50 million records. We also know of users who use MySQL Server with 60,000 tables and about 5,000,000,000 rows.
A very fast thread-based memory allocation system.
Very fast joins using an optimized one-sweep multi-join.
The server can provide error messages to clients in many languages.
This is only few features but you go to official site for more detail. And most important it's open source.
And the post help to install and configure on client system.

Convert Swing Application to 3tier application

After one year i have finished the development of my application.
Now when searching the internet i got a new knowledge about the 3tiers applications.
My Application running on 2tier Architecture (Standalone application connecting directly to database server).
My Application Developed using:
- Java SE (Swing).
- MySQL Server as database server.
I want to reconstruct my application to be 3tier application. (Client-Server)
- What technology i have to use?
- What I have to change within my current code?
- The application will run on network, there will be Many concurrent users who will use the application accessing the database (Insert,Update,Delete ... etc).
There are two main approaches. The first involves rewriting the client in HTML/JavaScript with help from one of the many available frameworks (Struts, Spring, Java Server Faces, etc.) Unless you specifically prefer a web application to a Swing application, or your user interface is a very thin layer on top of your business logic, then this is a costly approach.
The second approach involves inserting a server between your user interface and your database. Open source Java-based servers include Jetty, Tomcat, Spring, JBoss/WildFly and GlassFish.
If your code is structured in layers so that the user interface, the business logic and the data access code belong to separate layers, then converting from a two-tier system to a three-tier system should be straightforward once you understand the capabilities of your chosen mid-tier server and how to use them.
The basic technique is:
All user interface/Swing code remains on the client.
All business logic moves to the middle-tier server. The client talks to the business logic using a remote protocol.
All data access code is moved to the server.
Dependency Injection is useful to perform this refactoring step-by-step and also allow you to choose between working in two-tier or three-tier mode if that is needed.
The three main differences between a two-tier and three-tier application are:
Security - there is a new access point into your system. You need to be careful about the access rights it has to the database - do you have one server user that can do everything, or does each user need to use their own connection credentials. You also need to secure the server correctly and be careful not to add security holes in your mid-tier API.
Remote access - some method calls that were previously made within the same process are now made across the network. Server APIs generally need to support less fine-grained operations than local APIs, and the amount of data shipped as arguments and return values may also need to be managed.
The structure of your application becomes more important. The code isn't necessarily very different, but it will need to be organised into different layers.
Java EE is your answer.You could choose a framework like Hibernate/Spring/Struts to build a 3 tier architecture (MVC).You would also need to make a choice for a servlet container.Apache Tomcat should be a good choice.
It would be nice if you could post little more details like complexity , purpose etc. of your application.

Database for Google App Engine and desktop application

I need some advice. I'm new to Java EE technologies. Anyway, I would like to make my first JAVA EE project.
Imagine 2 client applications and server application.
1) Server. I picked up Google App Enginge technology to create server application. I would like to connect it to some easy database.
2) Client applications. I would like them to be desktop applications (or applications launched from the desktop) and these 2 apps also have to be connected to the same database as sever.
There was no problem to create this in Java SE environment - I had two clients applications with sockets staff and server application with socket staff. All worked locally.
But now I want to have server and database on the Internet and I want to make it in more professional way.
My problems are:
How to create free database from GAE? Is datastore the best option or something else? What's important - the client desktop application will also use this database. I'm looking for the easiest solution.
Maybe the solution is to create web client application instead of the desktop one - but make it look like it was desktop app (I would like to avoid using browser). I have no idea how to do this and if this is even possible.
Any help will be really appreciated. I'm stuck because my knowledge is too little to start. I have ma GAE app and I don't know what should I choose next.
Thank you in advance.
If you want make desktop application, you need to build backend application first.
check this out. You can use same concept with that. Build back end, and then create API to connect to your backend, and use that API in your desktop application.
Datastore is easiest way to store data. Check this out. Datastore have some limitation (such as didnt support join, many to many relationship, etc). Please consider wisely. Otherwise you can use Google Cloud SQL for your option, but AFAIK its not free.

Local Java Application - Database Selection

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?

Framework/Platform Selection?

So...I am creating software for a university. The purpose of the software doesn't matter. What I do need to know is, the best way to make it, and what technology to use.
The software needs to be able to accept multiple data sources, from Excel to SQL. However, the students will be using it primarily, and they won't always be on the schools network. I don't know if this should be created as a Web Application, or an app using Java (or something similar). Also, the students are going to need to be validated to use the software according to their current student status.
If I do this as a Web Application, and have it run off of the schools server, is this a better idea? Only thing is, this would require a lot of testing on their end as well right?
If I did this as say a Java program, can this even be done?
-Scott
If you want to use this application by students outside of schools network than a web application is the only viable option. If you will develop this as a Java program (I assume by Java program you mean a desktop application), you have to install this on every student's computer in school as well as home.
Edited in reply of your comment :
Regarding framework/platform selection, I would advise to develop this in what you know most. A good programmer can develop a good software in a language/framework/platform of which he/she has good knowledge and experience.
I'm assuming that a web technology will be best, because you can access it from any machine that connect to the Internet.
Java EE can manage this. So can .NET.
I'd recommend either one with Spring (Java or .NET flavor) as the framework.
The software needs to be able to
accept multiple data sources, from
Excel to SQL.
Spring will accomodate relational databases or Excel.
However, the students will be using
it primarily, and they won't always be
on the schools network.
A web app will only require Internet access. This could pose some security issues that you'll have to sort out. It's easier if they're on your network, because they're already authenticated as students and authorized to use your app.
I don't know if this should be created
as a Web Application,
I would recommend it.
or an app using Java (or something
similar).
Both Java and .NET can be written as either desktop or web.
Also, the students are going to need
to be validated to use the software
according to their current student
status.
Don't know what your security architecture looks like, but Spring Security can work as a cross cutting concern with databases, LDAP, etc.
If I do this as a Web Application, and
have it run off of the schools server,
is this a better idea? Only thing is,
this would require a lot of testing on
their end as well right?
Can be done. Testing is required no matter what.
If I did this as say a Java program,
can this even be done?
Hard to tell. No requirements, no idea of your capabilities, etc.

Categories

Resources