How to update android database by connecting to a remote location - java

Im looking to connect to a URL and download a file (.db) and if it is of a higher version then update the database on the app. e.g. currently using Database1.db and this online one is Database2.db. However I'm not really sure how to go about this. Im using sqlite.
Thanks

From server end:
Instead of uploading database from url you can post xml or json data
which will give details bout database version and sql query
From android program
connect to url get the data check for the version if version from url
is higher than that of existing one then execute the sql query that
you got to create database and take backup of your data
Scenario
Lets consider one scenario you have some data in a table named y in
old database. but the new database which you are downloading doesn't
have that y table but it has some new table then what do you want to
perform with that data. Do you want to discard or store if store and
use then to where you want to store.

Related

SQLite - Database minus list of values

I am working on project where I need to load data from local mobile DB(SQLite) to UI in meanwhile load data from server and when data download is finished insert the data from server to the database and update UI. I searching for way to download data from server and instead of delete all data in database and insert the new valid data just find the changes and "update" database. Is there some correct way to do this. I am working with SQLite database on Android phone.
SQLite isn't an online database meant to be ran on a server.
There aren't any free SQL Server options that I know of, but the NoSQL options include Firebase Realtime Database, Firebase Cloud Firestore, Realm Platform, Couchbase Mobile, Parse Server, etc...
Each of the listed options allow you to listen only to changes in the data. SQLite does not provide this option itself.

IOS Application Fetch data fro MySql Database

I'm practicing some IOS coding in Swift 2 which consists in an app fetching information from a MySQL database.
However, I'm confused in the concept. So currently my idea of how to accomplish this is that somehow the IOS App connects to the Apache Tomcat. To be able to do this, I though about creating a Java application that connects to the MySql using JNDI. With this I fetch the data and store it in a JSON object.
However this is where I get stuck. Should I return this object to the IOS application or store it in a text file or JSON file and have the IOS application read it from there?
If I had to return the object, how can I do this? I've looked around but most examples are fetching information from an API and currently I want to do it locally.
The easiest way is to create a PHP file to connect and retrieve data from MySQL, and then you call this file by swift.
You will find a useful information in the following link :
How to make an HTTP request in Swift?

Retrieve data from lotus notes database view via Java

I am trying to retrieve data from a Lotus Notes database within which I already have a view. I manage to create an ODBC connection and use this with MS Access or Excel but I'd like to create a scheduled job on a java application to inject the data in a MS SQL Server database.
I got a bit lost in all the documentation on Internet; Do
you guys have a sample of a Java code which would allow me to
1. Connect to the database
2. "Query" the view ("SELECT * FROM..."?)
3. Get a resultset which I can iterate through
I've read that I can avoid using the Lotus SQL driver by importing the notes.jar in my project...
Thank you for your help
The best and easiest way to connect to a Lotus Notes database is by using Notes API. All you need is to connect to the database, get the view and then traverse each document. You can accomplish this by including Notes API jar file into your Libraries and then you have all Notes classes at your disposal.

use existing sqlite database in java webapp

I have a java web app. I need to point to an existing sqlite database that I have in the project root (in eclipse).
I have all of the required drivers/jars.
The problem is that code to select from my sqlite database tables runs against a newly created database. I get an error that my table "Table1" doesn't exist. I believe this is because a new database is being created as opposed to using the existing sqlite database in the root with the tables and data that I need.
Does anyone know how I can force this local sqlite database to be used?
Per the SQLite docs, a new database will be created by default if it doesn't find an existing one -- so the most likely explanation is that the path in your connection string isn't pointing to your pre-existing database.
See the question here about relative paths in web apps: if your web-app is a servlet, use ServletContext.getResource to get the path to your database to use in the connection string. So, if your existing database is in /WEB-INF:
ServletContext.getResource("/WEB-INF/my.db");

SQLite, MySQL or Both for Android Application

I'm in the process of designing an Android application right now.
I understand SQLite works on the phone device within the file structure. However I'm not sure if it's practical for our use.
If I'm wanting to store data that's available to all users (i.e. if someone updates their profile, it can be seen by all other users), can that be done using SQLite somehow? Or must we use a client-server model such as MySQL?
Is it practical to store user-specific information using SQLite and public information using MySQL?
Thank you
What you want to do is a Client-Server Architecture, store the data in your central server and get a copy of the working data on the phone. MySQL and SQLite don't share everything but it's close. Read the documentation on SQLite and you will see.
SQLite can't serve files like MySQL if that's your question via the network. You'll have to write that on your own. I suggest making a webservice.
If you want info to be available to all users you need a client-server model such as MySQL.
If you use SQL Lite, the only possible way to update that info without requesting it from a server is to make an Update on the application (not doable).
Don't forget that you'll require internet ON for these types of applications.
you mean all users going to use a single phone, probably not, the reason for recommending sqlite database for android is that its the lightweight, non memory eater and thus best suitable to mobile phones. Sqlite database can be used in phone while at server side we can use any. The only thing is use a method like sending xml request to server from phone, where server will send respond as xml or json, while the phone parse the xml and use the data in it. this is how online apps works in mobile phones..... ya ofcourse use mysql at server side and do the communication using as request - response yes the client-server.
Is it practical to store user-specific information using SQL Lite and public information using MySQL?
Yes, This is exactly what I'm doing with my app. It's a very common practice. I am storing information in a MySql db stored on a server that all users can read from. They can pull specific information to the device. From there I have a class in the app that stores information that they've selected within a SQLite db. You'll easily be able to add information to the MySql db on the server that all users can view.
yeah i think the model you are proposing should have no problem. Even i'm using a model something similar to what you are saying. I store some information on local sqlite db and majority of information in mysql db. For sending data from android device to mysql db you will have to write a mysql scipt on a page and android device will hit that page with the help of http request. You can send your data in that http request

Categories

Resources