Access/Update a shared database - java

I need to share a mysql or ms-access database between a java swing application and a mobile device. The mobile has wifi access. The java application will run on my local pc (having no access to wi-fi i.e. the pc and mobile are on different networks) and will access/update the database. The mobile device will access a webpage (that utilizes the shared database) to get/post data.
If i host the webpage using free hosting (using either asp.net or php) and access it via mobile device, it can access/update the database. How can my local java swing application access the remote database on the free hosting website?
Is there another approach that i can take to achieve a shared database?

If your host allows direct MySQL connections (usually on port 3306), then you can access the remote database via the Connector/J JDBC driver provided by MySQL.
If not, then your Java application can access the database through the same PHP (or ASP.net) interface as your mobile application.

Related

shared SQLite db on windows with android applications

shared SQLite db on windows with android applications
I want write application android that install on some device android
I want Center Database for all of application install
I want shared one SQLite db on windows with my Application
I use Web Service but i want use connect to db with IP or (local network) or other way
thank you
I don' think you will be able to connect to remote SQLite database via socket (IP) connection from Android. Mobile data connections are not so reliable as LAN or WiFi on notebooks/PCs.
I think webService is the best solution for you. All your clients (Android apps, Windows apps) should connect to this webService.
Difference is that webService call it's just short connection (connect, send request, receive response, close connection), while database connection need to be persisted in time and can be interrupted, which may cause in inconsistent data or broken transactions.
EDIT: Other way is to use some MBasS (Mobile Backend as a Service). For example Parse.com. It could be your database and the provide their own REST API to access it.

Android SQLite and Desktop Sync

I am unable to figure out what is the best way to achieve a scenario like this:
Working on a project that would have android application as client.
User will take their device with the android application installed to field/visit and capture/punch/key data through out the day. This data would be stored locally on the device in SQLite database.
The data captured in SQLite needs to be exported out and imported into the desktop app (it could be java or .net based) for further processing.
Other points:
A. User could connect the phone via usb to desktop.
B. data flow would always be in one direction (i.e. Phone to Desktop).
C. No internet connection on the phone
My dilemma is how to access the sqllite database programmatically in desktop application? Are there any JDBC drivers that could read data from the sqlite database from a device connected via USB to the computer?
This is just a way to do what you want, there are more ways to do it but from my point of view is the most accurate and scalable.
You would have to make a webservices server on Java, PHP, etc ... with a database MySQL, MongoDB, etc ... and so the mobile device is synchronized with the database that was the cloud.
Thus after a desktop client would connect to the webservice to bring the data in order to process it on your desktop client.
EDIT:
You can view this post's
send-data-from-android-to-pc-via-usb
transferring-data-usb
bi-directional-data-transfer-through-usb-between-an-android-device-and-a-pc-mac

Can you create a connection between a Java Application to an Access database and while uploading the database to my website

I have written a few Java Applications offline before connecting to an Access Database but if I upload the database to a website and change the connection from e:// (filepath) to the file path of a webpage, would this work?
What would be the easiest way to connect to an online database?
This application would need to include:
Name
Password
Then Teams involved with each person registered
Maybe this could help you:
The Easysoft JDBC-ODBC Bridge provides JDBC access from Java applets,
applications or application servers to ODBC databases such as
Microsoft SQL Server, Microsoft Access and so on.
Being a Type 3 client/server solution allows the Java applications and
ODBC drivers to be on separate machines.
The client driver is 100% Java, eliminating the hassle of client side
ODBC drivers. It is compatible with any third party ODBC driver and
gives concurrent access to multiple data sources from multiple client
devices.
Importantly, it is built for commercial use with high transaction
rates and dependable performance.
http://www.easysoft.com/products/data_access/jdbc_odbc_bridge/index.html?gclid=COexrKf8h70CFagKwwod3UUAdA

Connecting Access Databases remotely?

Currently I have a Java application which performs all I wanted and the limitation
in it is "It only resides on the Local machine for which it needs to work". I have the Access Databases located on a Remote Server and I install the Java app on the remote server to connect the databases using a connection string jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=D:\\DATA\\DPPI\\DATA\\DPPI\\DPPIPR01.mdb;
It connects to Access Databases and do all the business logic with them.
Enhancements (to be done):
Making the application online - not a big issue.
Connecting the databases remotely - its the only concern.
If I make the Application Online the Access Databases need to be connecting through network (somewhat like IP or some web address).
Problem:
But after going through this Connect to Access database remotely It seems my requirement can not be completed.
Is there any way if I'm able to upload the database to the online web hosting server and access the database from there only? If yes, then how should I do the connectivity since Access Database connects by giving the fully qualified name containing drive letter and all.
But how should I proceed further so that I may be able to connect the mdb Databases remotely?
ADO Solution:
But after going through the link: http://webcheatsheet.com/ASP/access_connection_strings.php, it seems we can perform remote Access Database connectivity.
The solution for the ADO is something like:
connectionString="Provider=MS Remote; Remote Server=http://your_remote_server_ip;" &_
"Remote Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\your_database_name.mdb"
I'm a tad confused to how Access Database we can connect.
There is one more question in my head.
I'm making use of Type-1 Driver. Should the Type-4 Driver support the remote connectivity?
If your application is a server side application (like a web application) and your server's OS is Windows then theoretically it is possible to use your Access database. In this scenario, the Access database is local to your application. In your connection string you can simply use the path to the Access database inside your server's file system.
But keep in mind, that Access is a desktop database not made to use it as a server database. This can lead to poor performance and maybe system crashes. And it is possible that there are some licencing issues for this use case.
So even it may be possible to use Access with a server application it is strongly recommended to use a real server database like MySQL, MS SQL Server, etc. Even an embedded database like Apache Derby or H2 would be a better fit.
If your application runs at client side like a fat client, then your only chance to use Access is to put it on a network filesystem, so it is visible from every client. But this works only inside a LAN. If you cannot put it on a network filesystem then you have to use a real server database.
Do not use Provider=MS Remote (RDS) for new development. Here is a quote from the MSDN article
Microsoft OLE DB Remoting Provider (ADO Service Provider)
Important
Beginning with Windows 8 and Windows Server 2012, RDS server components are no longer included in the Windows operating system (see Windows 8 and Windows Server 2012 Compatibility Cookbook for more detail). RDS client components will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Applications that use RDS should migrate to WCF Data Service.
As others have suggested, you should seriously consider using a different back-end database for this particular application.
What if I'm able to call another java application residing on the Server housing the Microsoft Access Databases? Can you please let me know if it can be the solution such that I will have the division of my application into two:
1. The Online java Application performing 2 things: Accepting the requests coming in and waiting for the response to come from another application running on the Server housing the Microsoft Access Databases.
2. The Java application installed on the Server housing the Microsoft Access Databases only responsible for connecting and returning the DTO (Data Transfer Objects) -or some kind of objects in Collections.
So, I would expect a serverside program to handle the communication with the DB and the client application would communicate with the server app.
Please let me know if I should proceed in this manner.
it can be done by marking the traffic and queueing the traffic from the server---to----remote site ---(QOS..quality of service ) .....the two sites will be connected through VPN methods to reduce the unnecessary hops that will improve the latency plus add the security , thus server and remote site will logically act as if they are on the same network (LAN)
regards ,
Ali Rehan

How to access shared hosting database with Java desktop application

I was looking for a solution for one of my questions. I have developed a Java desktop application. I have a database in a shared php hosting server. Is there any possible way to connect the shared hosting database with my Java desktop application. And how can I perform timed database synchronization with the shared database server
Thanks in advance
Mujahid
If the shared hosting provider allows SSH file transfers, check to see if you can create a tunnel to the database server, and configure your desktop application to use that tunnel to connect.
Probably not, for security reasons %99,99 of shared hosting servers would not allow that.
However you can programm a gateway php string that interacts with db on the server side. Then you can connect to this php script from your java app:
your java app <-> php script <-> db

Categories

Resources