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
Related
Should I do the "Embedded Database" if I want the program I created with the database to be able to access another computer?
I finally export my Java application as an executable file/application file, but my only problem is that its database needs to be always connected to the database I created. So, when I run it, It runs perfectly but I cannot access my database unless the NetBeans is running in the background. But I want it to be able to run independently without NetBeans and needing to connect to the database every time so that I can run it to my other computer. I read that I should create an embedded database so that when I try to open the file to another computer, the database is included.
Is my understanding right? I created a database using JDBC.
if you want to connect to your database in other computer,you'd better create your database on Server which connected to the Internet.
It depends on the type of application which you are going to develop.
If your application is a single-user standalone system then it's perfectly fine to use an embedded database. Example: Single-player game.(In here application's database is hosted within the user's machine so other users can't access those data)
But if you are developing an application which is having more than one user and those users need to share their data with others then you should go for a database like Amazon RDS which is hosted on the cloud, because then you can share those data among all the users.
(Ex: Microsoft Teams Application)
Finally, I should say yes you don't need to have NetBeans working if you select either one of those options.
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.
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.
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.
I'm currently developing a Field-Service application that stores data in the local sqlite database on an android device. At some point, usually after completing the data collection rounds, the local sqlite db is to be synchronized to a remote sybase db on the server.
Any suggestions as to how this could be achieved or engineered as a solution? Or even better, are there alternatives to synchronizing data in such an application?
There are two general solutions that come to mind:
You could have the device send the data to your server in some sort of text format (json, xml, etc) and implement a web service that collects the data. However, both the device and web service will need to understand the protocol.
You could also have the device send the raw database file to a web service and have it open the database, read the file (via SQL) and copy out the necessary bits. However, this couples your device and server to the database schema, but might be less work to actually send the data.
Either way, you'll need some sort of web service to listen for the data that the device wants to send back. The only sticky part is which mechanism you choose.