Create an internal Database for Java EE? - java

I'm creating a web application, possibly using Maven, Spring and Hibernate.
I need to create a database for the application which will obviously hold some data, however as I need to send the application to someone once it is finished so that they can run it on their machine, I am not sure how to create the DB.
I have developed Android appliations previously where I have used sqlite to create an internal database, and I was wondering if there is anything that I could use similar?
Or will I have to use something like phpmyadmin?
Thanks for any advice.

Related

How to access MySQL database in jBoss BPM suite process

I am newbie in JBoss BPM Suite. What i want to achieve, is to access my MySQL database through a business process. I have already added a datasource to my application server including the jdbc driver. What i tried to do was to connect to my db by a script task. Although i got an exception ClassNameNotFound for my driver class 'com.mysql.jdbc.Driver'. What is the right way to connect to the db? Is there a way to do this by a service task? Or a WorkItemHandler?
Thanks in advance.
It is not recommended to execute any complicated logic (like accessing the database) in a script task. I would also assume that your application server does not put database drivers on the classpath of its applications since it is against the whole idea of datasources. You just need to make use of the datasource you have already configured.
When it comes to the right way how to connect to the database inside your process, you will need to implement your own work item handler where you can get your data from the database. There are many different ways how you can achieve this. You can find inspiration from JPAWorkItemHandler which will be available in version 7.
I have finally made the connection to my database by creating a WorkItemHandler and add it as a dependency to my BPM Suite project. After a lot of search, i think this is the best way to do it if anyone wants to access his database in a business process.

I want to ensure MongoDB is available when my Spring Boot server starts

I am newer to distributed development and I am attempting to write a web app with the help of Spring Boot and building through Gradle. Yesterday's goal was to input form data through the web and then, through my REST API, store this form data in a MongoRepository and, finally, bring it back from the repository and display to a new view. I'm having success with all of this.
As I am thinking ahead, I am realizing I know nothing about how this all works when deploying to "go live" on the web.
The key piece I am wondering about is what a good (and preferably clean or simplistic) way to get my "mongod" and "mongo" commands to go as part of my web app starting up. I apologize if the terminology I am using is vague. I have a main method using Java 7 in my Spring Boot Application (annotated appropriately) which I am currently, to run locally, just asking eclipse to run my app as a Java application and that tells Spring to bring up a local Tomcat server to host my app. I think I have all that correct in my head, but I am having to manually start my mongo database prior to that by using the CLI for mongo.
Ultimately, how can I automate starting up my mongodb as a part of running my app as a java app?
As mentioned in the comments, you're thinking about this the wrong way. Your databse (Mongo or otherwise) is something you should assume to be up and running already, but prepared for if it isnt. This means your startup pseudo-code will look something like
doNormalStartupStuff();
try{
connectToDb();
}
catch(UnableToConnectToDbException e){
log.fatal("Unable to connect to database, shutting down");
//possibly send alerts out
shutdown();
}

How Connect to Remote MySQL server through Android App via JDBC

I first successfully connected via JDBC to a remote MySQL server with a Java program. That I understand how to do. My goal is do the same thing with an Android application and display data from a remote MySQL server.
Question 1 Can someone explain the process outline to do this via Android ? (I am new to Android and am a little stronger with Java, could use a little guidance).
Question 2 I found this tutorial on javatutorialpoint.com titled: Android MySQL Client but it wants me to use the SOAP API. Not sure why, if someone could explain.
Not asking for it to be done for me. I just want someone to outline the main steps in order to make it happen. Just the process that needs to occur is all I am asking.
Question #1:
I stumbled upon this link some time ago:
http://docs.oracle.com/cd/E17076_02/html/installation/build_android_jdbc.html
(Disclaimer: I haven't read the whole tutorial myself)
It tells you what's needed for getting the MySQL connector to work with Android.
Basically, from what I know, the standard MySQL connector for Java, doesn't work out of the box for Android. You'll need to build it on your own.
After building the connector, you can include it in your Android project, precisely the same way as you do in a normal Java project.
Your Question #2:
SOAP is a mere layer of abstraction, for not working directly on the database. If you use a layer like SOAP, you can swiftly change your database layer without affecting much of the communication from-and-to the Android app.
You can use the same methods in Android you used in Java (Android is written in Java, after all, and you are able to use the majority of its libraries in android). However, be careful with doing so.
It would probably be better from a security standpoint to set up a web service to communicate with the database, rather than you allowing your android app to communicate directly with it, which would actually require you to embed your mysql username and password in the app code. A SOAP or RESTful web service could enable your server to communicate with the DB and then serve the data from it to your app.
It's done the same as in Java (Android apps are build in Java unless you're using the NDK).
You don't need SOAP if you only want to get data from a remote DB.
See this question.

Accessing existing SQLite database using Eclipse

I have created an android app in java using eclipse which creates a SQLite database and lets the user add data to it.
I would like to know how to access an already existing SQLite database (say, in our web server) to view and add data to it ?
I Googled it and didn't get any clear picture. Do I need to install JDBC driver for doing this ?
Thanks.
SQLite is not a client/server database.
That said, the SQLite wiki mentions some alternatives.
If you want to access a remote database from your app, you will need an interface (like a web service) that will take requests from your app and actually do the database manipulation. If you just want to access a local database from your computer, there are several utilities for it to do it graphically or you can use sqlite3 to do it from the command line. If you want to access the database through your browser, I think you need a web service for that too.

Application that provides local and remote access to data

I need to develop an application with following features and want to
understand if GWT can be used to develop this application or is it the
right technology to use ?
1) Backend is in Java and uses MySQL
2) Desktop based UI to create some datafiles and data will be stored
in MySQL DB. This app will generate the data.
3) A desktop based application using which users can get access to
that database on a CD. This app will provide access to data locally
stored on a CD.
4) A web interface using which users can get access to the database
remotely. This app will provide remote access to data.
For local access also, we have the flexibility to install and run the
web server.
Should I use GWT for the UI part or should I use some thing else ? I
would like to provide common UI, look & feel for local and remote
access to data.
Please advice.
Thanks,
Deep
As you can run the web server also locally, I don't see a problem to re-use the same GWT app for both use cases.
It would be harder if your users must communicate with both the remote and local server from the same browser window/tab, at the same time. That can only be done with JSONP, which is possible with GWT, but it's not as nice as GWTRPC.

Categories