Android app extern database server - java

When I want to create an SQLite external database for android application, do I have to have a server with database that is always running?

Yes, since it will be on a server. If the server isn't running, then your application won't be able to get any data from the database.

There's a very important distinction that we're missing here - what it means to have a remote database.
SQLite is a flat-file embedded database engine. You don't have a separate process running SQLite in the background like you would one for MySQL or PostgreSQL or Oracle, nor would you really want to - SQLite as a database is pretty limited in what it can do.
If you say that you're going to have a remote SQLite database, then that implies that you have some server somewhere that writes to and reads from this flat-file database. If you can finagle that somehow, and make it secure, then more power to you - and yes, you could have this accessible remotely for your intents and purposes. Trust me though, you wouldn't want to.
What you're likely looking for is a way to remotely run MySQL or PostgreSQL instead, as these are proper database management systems (DBMS) which will be able to both service remote connections and give you a more expanded set of the SQL language.
Ultimately though, the database server must be running at all times. You wouldn't be able to connect to the database if it's down, and you don't know the lifespan of the app (or when it's going to be accessed, etc).

i got the below information from SQLite home page
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
Based on the above statement you don't any server. I hope this information is useful to you.

Related

Java Derby DB in embedded server mode Change Listener

I'm developing a web application and I am using Derby DB in embedded server mode (embedded and server/client mode). The application is such that when multiple machines connect to it, they share the resources of the database, obviously.. But when one machine queries a statement to the database and changes the record, I need a way to "notify" other machines of the change in the DB so that they can update their UI respectively. I looked for a way to register a Listener to the database, which is going to fire on updates.
I had a look at several questions here, including:
How to implement a db listener in Java
How to make a database listener with java?
But I couldn't find any solution regarding Derby DB. I simply don't know where to start from, here.

Java Embedded Database to Standalone Database

Im workings on java project.its a desktop application (financial application).
I want to when user in offline save all data in embedded database (H2 database) and when user come to online or click on some button save all the new data on Standalone database(My SQL server) server.
Right now i kindda lost with this scenario.
Can some one describe how this should be done or is this possible.
Based on Assumption as your question seem to pointing below requirement,
you have local H2 database
mysql may be on other network.
If you save some data on application then goes to h2 database
one you connected to internet the data should go to mysql database which is on differnet host from h2 local database where application is running.
Solution :
you need to add replication tools which replicate data from one database to another seemlessly.
Refer One of the nice tool : https://www.symmetricds.org/
Let me know if you have any other requirement. Also please provide enough details when raising the questions. Thanks.
Replicating data from H2 DB to Mysql DB using a replicator tool is one way.
Other way to achieve the same is rather than creating a heavy in-memory DB instance on client machine is you can write the same data in file on client machine at some location and write a scheduler program which will check the heart beat of socket and if ping to your server is successful you can read file and upload the data to your actual DB server. Also Writing your own scheduler and data uploader will give you more control.
Other issue with any replicator tool is data type compatibility.
Still if you want to go ahead with any replication tool- you can have a look at Tungsten Replicator - https://docs.continuent.com/tungsten-replicator-4.0/deployment-oracle-fromoracle.html

Java integrated SQL server

I'm working on a plugin for an emulator that is going to allow people to host a control panel through a website to view statistics, etc; Currently I have XAMPP installed which is running my SQL Server, and the HTTP Server is being handled through the Netty networking library in Java.
I'm curious as to if there is a way to host the SQL Server from within Java, similar to the HTTP Server. It'd also greatly simplify the process of installation for the plugin.
The other option was to use ObjectDB, but after looking into it, it seems like it requires Quercus and I don't want to go through that.
The term you're looking for is "embedded database".
There are a number of databases that you can use as an embedded database, and you can choose to use them as an in-memory database (which means the data is gone when your application stops) or make them save data to a file on disk, so that the data is still there when you stop and re-start the application.
Examples of databases that can be used in this way: H2 Database, HSQLDB, Apache Derby.

Can I Query MySQL Database Directly from Android without a Web Service?

I have a Linux server which has a Database. I want to query the Database from my Android application.
All the tutorials I find tell me to use PHP for some reason.
Can't I just query like I would normally with a Java application? Which is, I connect to the Database then send my queries as Strings.
It seems I need something like this:
Why?
PHP is just a server-side programming language. You can use any language and any server. The main issue is
Can I Query MySQL Database Directly from Android without a Web Service?
Yes you can. Just open the port where your MySql database is set usually at 3306. You also need JDBC Driver to set up connection to it.
Should I Query MySQL Database Directly from Android without a Web Service?
Unless you want to make a Database Client app (like phpMyAdmin) where each user holds his own credentials then you should not. In such case everyone will be using their own credentials to access their own db. In your case, you'd be hardcoding your database credentials in the app for everyone to access.
Well, your database user is only allowed to connect from localhost not from the outer world. If you want to execute queries from outer world then you will have to allow access from all IPs i.e. You will have to create a user create user 'app'#'%' identified by password123 (In my opinion it will be a bad approach).
Moreover you can build REST Web Services either using PHP (Recommended) or JAVA to interact with the database without opening it to world wide.

Desktop app with local and online database

I want to create a Desktop App(Software), preferably in Java, which connects to a central MySQL DB on a local network whenever available.
I also want it to store and use a copy of the same DB when the central DB is not available, and sync whenever the central DB is available.
How can I store data locally, I mean which kind of database should I use for local database?
Also, are there any tools which speed up the Desktop App development?
Let's suppose that you will implement your solution in Java. You will need some classes (i.e. Data Access Obejcts, DAOs) in charge of interacting with the database on the network and on a file based database embedded in the application (the "local" database).
What you need:
A local database that you can ship with your application like H2 www.h2database.com, HSQLDB http://hsqldb.org/ or Derby db.apache.org/derby/.
To develop your DAOs (using JDBC or Hibernate) in such a way that you can instantiate them with different drivers, URLs, login/pwd and use only SQL standard / functions supported both by MySql and by the local DBMS. In practice you must avoid using DB specific functions.
You can use Hibernate or JPA for example, they have quite a nice and easy integration with your application.

Categories

Resources