Simultaneous access SQLITE JAVA SERVICE / CordovaJS APP errors - java

Aloa
I am trying to make an app (Android to begin, and then IOS) that one side (JAVA) executes SQL statements on a database stored on the phone (imported once from the www folder and using SQLiteOpenHelper ..) in java from a background service starting at the boot. No worries on that side.
On the other hand (CordovaJS) I check / update the same database from the same application, but in the GUI (webview) via the cordova Cordova-storage-sqlite plugin. No worries either on that side ...
But when JAVA and CordovaJS try to use the database at the same time, the app crash sometimes...
How can I do to access to the base of both sides simultaneously?
Otherwise what would be the best solution:
Create two separate databases with the same information that I would need to synchronize regularly between JAVA and CordovaJS in the two ways? Synchronization can possibly lead to the same problem of dual access ...
Create two bases, and communicate via flat files containing JSON data ...
Not to use databases and move only by flat files in JSON?
Any other ideas?
I'd rather largely retain only one database ...
Thank you in advance for review
PS: Sorry for my English, I'm French :(
EDIT:
Here is one of the errors occurs: W/SQLiteConnectionPool﹕ A SQLiteConnection object for database '+data+data+com_app+databases+db.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
An other error seems like android.database.sqlite.SQLiteException: error code 5: database is locked

Related

Sync SQLite DB on android studion with MySQL DB on web server

I am developing an android app that measures the radio interface parameters of a network periodically, stores the data in SQLite DB and transfers the data stored to MySQL DB on a web server. How can I make this possible?
I've done some research on this and found only one usable option, which is to make a web service using json or xml to pull/push data between the two databases. You could create a database link between the two, but this is not advisable.
There are numerous questions with a more detailed scope for this issue and you should be able to find one that fits your use case. If not, ask a new question after this research with more details and what you've done so far.

Concurrency embedded Java Database for simple Application

I am trying to build a simple GUI in which you can write some Integers. These Integers are supposed to be written into a Database, which I am looking for.
So far so good. The data in the Database should then be used for another stand-alone application, which already exists.
I tried it with SQLite already but I received a lot of "Database locked" Errors. I searched Google. The key answer I often read about was to switch to a database which supports concurrent processes.
I went further on and had a look at H2 and HSQLDB. Both of them seem to be legit but much more complicated.
So I wonder:
I would like to have the GUI to be portable in a .jar file (or a folder only) combined with the Database, so when I switch computers I do not have to install the DB in a certain folder like the home-directory or something. With SQLite all you do is this:
Connection con = DriverManager.getConnection("jdbc:sqlite:test.db");
As you can see, no Path-infortmation is necessary. How can I do this with H2 or HSQLDB?
I am really looking forward to your suggestions. But only open source please.
Kindest regards and thank you very much!
Stefan
With H2 and HSQLDB you can do the same.
With H2, a database URL of the form jdbc:h2:test will create a file called test.h2.db in the current working directory of your application. If this is what you want, then that's fine. Please note I usually don't suggest to do that, because many people run into the problem that they sometimes start the application in a different directory (which will then create a new database). Because of that, I suggest to use jdbc:h2:~/test, which means the database file is stored relative to the current user home directory.
Handling the creation of an embedded db file should not be a big issue - but if you really dislike this stick with SQLite: it should handle concurrency well enough for basic usage - 'database locked' sounds more like an application level problem

Computer Vision application(+web interface) for face detection and recognition from database

My project is a computer vision java application which should implement the following :
A web interface through which the form entry+images(for example a student data) will be stored into a database(Mysql) & images into directory common to my java application.
Then the data & images can be retrieved from my java Gui application and I can perform the following operations of image processing through OpenCV.
Actually,I want to run the face detection on images retrieved and discard the false entries(no proper face).
Also the application user/admin can search an image based on text search(By Id) or By another reference image using face recognition.
I am well familiar with Java but the problem is that I need a guidance on how to organise it in a stepwise manner(links appreciated).OpenCv,Php and mySql are really messy.I know doing the openCV stuff within java is real overhead but i really want to do it.But If there is any suggestion to do it elseway please guide me.So any kind of help is a ray of hope for me.
Thanks.
This sounds like a nice application. Here is what I would suggest you:
1- A web interface through which the form entry+images(for example a student data) will be stored into a database(Mysql) & images into directory common to my java application.
You will be able to easily create such application with Php and Mysql, just look for some tutorials on image uploading and php.
2- Then the data & images can be retrieved from my java Gui application and I can perform the following operations of image processing through OpenCV.
I'd recomend you using JavaCV. It is a wrapper over OpenCV which seems to work very well from some tests I have made. You get the flexibility of Java and the performance of C++ through a native bridge.
3- Actually,I want to run the face detection on images retrieved and discard the false entries(no proper face).
You can easily adapt the OpenCV face detection code to JavaCV: http://opencv.willowgarage.com/wiki/FaceDetection
4- Also the application user/admin can search an image based on text search(By Id) or By another reference image using face recognition.
The search by id is easily accomplished through some JPA or even JDBC connection. Now the similar face search is tricky. I'd point you to this link http://www.shervinemami.info/faceRecognition.html about face recognition in OpenCV.
I hope that helps.
Best regards,
Daniel
Here how it can go as far as I can suggest though will need to take care of issue that might not be addressed here.
You will be creating a webservice that will be accessed directly for to upload images. The same service can be used to download the images from your Java application. So make sure you have created a well defined service that takes care of these two distinct operations and are cleanly exposed to the outside world. MySQL will be the back end DB that shall take care of storing either student info and/or images themselves. You can write a service without MySQL and just have the service store images and/or student info locally (at the server end) and later on you can develop code to integrate MySQL. A good and simple link to MySQL and Php
JavaCV Would be the candidate for your java application. You will leverage the power of OpenCV easily. Develop the application and test it against your service. Try just downloading some image from the service first. If that works, go on to Image processing part.
Make sure you undetstand Face Detection and Recognition. These are two different things. From the OpenCV wiki FaceDetection and FaceRecognition
Searching via id/text string would be trivial if you get through step one and understand querying data. Searching via image would me you would store the face recognition artifact (vectors,dimensions,eigen values etc..whatever). Once store on your server, your application will then send off a input image artifact to your server where matching will be done and result returned.
**
To summarize
**
Connecting your webservice and MySQL via connectors such as JDBC. This is very important. No SQL connection, means no DB and a useless service.
Service taking care of student info upload/download.
Image processing. Face artifacts calculation must be common. Same code can run at server and client (makes sense, doesn't it?).
Querying for search either by string or image. Two different types of searches. Client must tell what type of search the server should do.

SQLite on Google App Engine

Is it possible to use SQLite as a relational database from Google App Engine? (Java) I need read/write access to it from the app itself.
Also, I am using Quercus for PHP, and if what I am asking for is possible, I can handle storing the database myself.
No, it is not possible. This would require write access to the filesystem, which App Engine does not allow.
SQL database support (MySQL like) is planned, but no release data has been given. For now, use the datastore.
I know it's a super old question and nothing concerning read-only properties of App Engine has changed since then... But actually you can use sqlite on Google App Engine. There is a writable /tmp directory (https://cloud.google.com/appengine/docs/standard/java-gen2/using-temp-files). If your app on startup first copies the db.sqlite3 file to /tmp/db.sqlite3 and references this path as database path, it will work.
The following problems are connected with this approach:
This directory is "in-memory". So if you want to use really large sqlite file, you may face problems with RAM.
Each node of the app gets its own copy of the database. If you save something on one node, these changes will not be seen by other nodes. And the new data will be lost if the app scales to 0.

sqlite3 table creation with java in android

I'm working on creating a checkbook app for android using a database to record transactions. The design I'd envisioned was/is to allow the user the ability to create different "accounts" (savings account, checking account, etc) under whatever name they choose and use that as the database table name. However, using preparedStatements doesn't work when I try to create a table. So I'm wondering if I'm going to need to sanitize the input manually or if I'm missing something. This is my first Java/android database program and I've got no formal education in databases so its possible I completely missed something. **edited to reflect more accurately what I meant by account. As this will be on an android device I have no interest in multiuser setup.
Probably, you don't need a table for each user. You should revise your database structure.

Categories

Resources