Closed ZaheerUdDeen closed 6 years ago
We have extensive documentation in the README, in the doc directory and in the javadoc.
You should be able to get started easily enough:
To implement the following https://github.com/cloudant/sync-android/blob/master/doc/CrudSamples.java CRUD sample in javaSE, I am facing the error below. I have tried the to get the answer from different forums like StackOverflow & google etc but failed.
below is what exactly I want to try :)
I have also added dependencies of slite4j.
You can see it in my reference library.
Kindly Help. thanks.
Hi,
It seems you are missing the SQLite4Java libraries. Sync-Android has dependencies on it. I've had the same issue some time ago. Are you deploying your program on the Raspberry Pi? If so, you'll need to add this library manually.
Check this link for more info: https://stackoverflow.com/questions/21750601/sqlite4java-on-raspberry-pi
No I am developing the application in JavaSE desktop application with javaFX in eclipse.
Can some have the solution to this problem, please?
You need the native DLL for sqlite4java: https://bitbucket.org/almworks/sqlite4java/wiki/GettingStarted
Depending on where you install that DLL you may need to give your java program the path to this DLL by setting the flag
-Dsqlite4java.library.path={path}
Note that we included the native libraries for Linux and MacOS in the native
sub-directory but none of us test or develop on Windows - sorry about that.
I have tried this: https://bitbucket.org/almworks/sqlite4java/wiki/GettingStarted I have no idea to set the flag(-Dsqlite4java.library.path={path}) please, any guide to do this?
You need the value of the system property sqlite4java.library.path
to be the path of the directory where you put the SQLite4Java native files (e.g. *.dll
) you downloaded for your platform.
I have set System variable path under system property(As below)
This is the directory where all the native files are available.(As below)
This is the project build path(As below)
The same error exists.
You've got the wrong gradle dependency, I can see cloudant-client-2.11.0.jar
which is java-cloudant but you're trying to use sync-android (project name is android but it works on JavaSE too) here. As per https://github.com/cloudant/sync-android#gradle-or-maven point 3, the dependency is:
dependencies {
compile group: 'com.cloudant', name: 'cloudant-sync-datastore-javase', version:'latest.release'
}
You can use both, but java-cloudant doesn't need sqlite like sync-android does.
I am already using this dependency for android-sync
And dependency is already included in "project and external dependency"(As Below)
Now let me know if it is possible to use java-cloudant for the offline first (java-SE) application. if this library(java-cloudant) provide offline first functionality linked some helping materila or sample project that should include. 1.Database creation
By creating another project and doing everything fresh the above error has been managed, but unfortunately, the following error started arising.
This is the code what I am trying to do is. (As below)
Below is the error that is arising.
Re: this comment
I will try to clarify the differences between java-cloudant
and sync-android
, both of these projects use the Java language and can run in Java SE.
The cloudant-client
from java-cloudant provides Java APIs for interacting with a remote Cloudant server - it has no local datastore so has no built-in offline first capability. If you wanted to write an offline first application using java-cloudant's cloudant-client alone then you would have to write all the local database and replication functionality yourself.
The cloudant-sync
artifacts from this (sync-android) repository are code for creating and managing local databases and establishing replications between the local databases and the remote Cloudant. The artifacts are published for both Android and JavaSE. If you want to develop an offline first application then the sync-android JavaSE dependency (group: 'com.cloudant', name: 'cloudant-sync-datastore-javase'
) is the best one to use.
RE: this error
The class that cannot be loaded com.cloudant.sync.internal.sqlite.sqlite4java.SQLiteWrapper
is included in the cloudant-sync-datastore-javase-2.0.2.jar
. This jar is part of the group: 'com.cloudant', name:'cloudant-sync-datastore-javase'
dependency so it should be available on the classpath when you are using that dependency. I would recommend double checking that your application classpath correctly includes that jar at runtime. If you are using Maven or Gradle then the necessary jars and all the dependent jars should be downloaded and included in the classpath. As you have seen besides the jars you also need the native library and sqlite4java.library.path
property to complete the configuration of the SQLite4Java dependency.
Hey Guys Great, Everything working now on >javaSE.
One more help, under this thread. How can I create a database on cloudant server using >sync-android programmatically? what now I am doing is: I am manually creating a database(>tasks) on cloudant server. Then I put my database name here (As below) to replicate the local document store with an online database that I just created in cloudant server.
But what actually I wanted to do is, to create the database on cloudant server programmatically and then replicate both the local document store and online database in cloudant server.
Since sync-android is designed for on device we recommend that it does not have Cloudant admin credentials, but rather uses something like an API key with replicator permission. Since an API key can only be generated once a database exists and a database can only be created by admins we do not provide a programmatic API in sync-android for creating a database to discourage the client side storage of admin credentials.
Usually sync-android users would run another server based application to have a sign-up or similar that creates the necessary Cloudant server side resources.
If you really need to create Cloudant databases from the device, and understand the security risks inherent in storing admin creds on the device, then you can create a database by making a HTTP request to Cloudant's HTTP API or using a library like java-cloudant alongside sync-android to do so. For example you could add the java-cloudant group: 'com.cloudant', name: 'cloudant-client'
also to your application and use its createDB method.
closing, no further action
Please include the following information in your ticket.