Storing Setting Information - java

I am developing a web application and this web application is to be sold to many people. The application is being developed in Java Spring. The application has a database and when sold this database could be on different locations.
Where is the best way to store this database location so the Java code can find the database?
I would store it in a XML file but where would it go, so that the database location can be changed easily by someone.
I don't want to store it in the Spring Beans. Is there another way?

The problem is that it's a web application, which suggests that you'll give them a WAR file. All the Spring configuration and properties will be packaged; changing something will mean opening the package, which you don't want them to do.
You should set up database access using JNDI names, which are set on the app server the package is deployed to. Give instructions to show how to set one up for Tomcat and other app servers. When your app starts, it'll get the data source name from the app server.
You're assuming that they'll be sophisticated enough to be able to create a JNDI data source on their app server or that your documentation is good enough. Good luck with that.
Another thought would be for you to create a small in memory database like Hypersonic or Derby that comes with configuration information for your app. Tell users to put it in a location outside the app that you specify (e.g. c:/yourApp/configuration), provide a script to start it up when the app starts, and let your application query for database connection information when it loads.
Now you'll be counting on them knowing how to create INSERT or UPDATE queries for your in-memory database. But your chances of writing documentation to instruct how to do it are better, because you don't have to figure out how to do it for WebLogic, Tomcat, Jetty, JBOSS, WebSphere, Glassfish, and every other Java EE app server.

Related

Is it possible to make Camunda Webapps (Spring-boot stand alone) update .bpmn through Tasklist via DB or Rest

We are trying to deploy Camundas webapplications as standalone spring-boot application and also deploy .bpmn diagram and engine in another stand alone Spring-boot application. But only connect the two SB-apps via a shared DB or REST-calls, and still be able to update the task through Camundas webapplications.
We have managed to deploy them and connect them to a file based H2 database. So now we can do rest-calls to the .bpmn Spring-boot app and submit forms etc. and then make it show in the Webapps-tasklist/cockpit.
The problem is that if we try to submit the form through the tasklist, we get an error that it’s trying to look for a javaclass (which we have implemented in the engine-SB-application but not in the Webapplications-SB-application).
Is there any way to make it so that we can use the web-apps-tools and submit the form from there (without changing that the .bpmn diagram uses java-classes)?
Either through making the webapps update the database, or maybe through REST-calls?
We solved it by using Asynchronus Continuation.
A very good video about can be found here:
https://www.youtube.com/watch?v=Nx4I8lNMUs0

Upload Spring Project to github account with/without server and how do I embed mysql database

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

Deploying a Java web application to Amazon

I am sure this question has been asked and answered before multiple times. But unfortunately, I am still not clear. Here is my issue.
I have a JSP, Servlet application which uses MySQL as the database. I have built the WAR file as well. Now I am in need of deploying this so it can be accessed online by anyone.
I looked into lot of areas including normal web hosting. However even though the services like DailyReazor are highly secured, they provide little for MySQL, around 250 MB for the package I selected.
Now I am looking into Amazon AWS. In AWS I am expecting to deploy my aplication and make it available online.The MySQL server should not contain limits like 250MB.
But I have never ever used this service AWS before. By reading various posts, I know that Elastic Beanstalk is the easiest way to go, but still not convinced about how to deploy it properly with database access and all. And in the other hand, will they give me a web address like "www.example.com" or will they simply provide an IP address?? I am also familiar with tomcat so I need to use it.
We will not upload files (images etc) at the moment, so I believe we can manage with around 20$ per month?
I really appreciate if someone can provide a clear guidance on deploying java web applications in Amazon, with the requirements I mentioned about MySQL, Global access and so on.
Amazon RDS for MySQL is a Database-as-a-service offerring from AWS. It is scaleable up to 3TB, and has scaleable IO as well. Of course it also depends on how much you prepared to pay. they manage the DB for you (backup etc). You get a URL to connect, credentials and you are set to go.
Amazon Elastic Beanstalk uses Tomcat. So you should be familiar with that. You upload your WAR file and specify what EC2 flavor you want (CPU/MEM etc). They launch a VM that is configured with Jva and Tomcat and deploy the WAR for you. You get an IP address.
Amazon Route 53 is the DNS service, where you can assign the IP address to your domain (assuming you have one)

Shared Database in application and webserver

I wrote an application which uses a SQLite database, now I want to extend the apllication with a webinterface.
Since I want everything to be in one application with no need to set anything up or install something else I plan to embed Jetty in the application and then install some CGI servlet to use PHP.
The application and the website should be able to modify the database.
This is most likely not to be accomplished with SQLite.
What ideas do you have to accomplish this? Important is that everything can be integrated into one application.
Ensure you access the database only via a javax.sql.DataSource definition from JNDI, and you are golden, as both sides, both the Application and the WebApp will have the same access patterns, techniques, rules, etc ...

java apps with mysql database

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!

Categories