Hello. As an example of using SpatiaLite, "[Language bindings: Java / JDBC] (http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/java.html) "I found (SpatiaLite Cookbook), so I tried running the source (SpatialiteSample.java) SpatialiteThreads.java).
I installed the following as a preparation (using homebrew).
$ brew install sqlite libspatialite
$ brew cask install java
$ wget https://bitbucket.org/xerial/sqlite-jdbc/downloads/sqlite-jdbc-3.16.1.jar
Execution
$ javac -classpath ".:sqlite-jdbc-3.16.1.jar" SpatialiteSample.java
$ java -classpath ".:sqlite-jdbc-3.16.1.jar" SpatialiteSample
SQLite version: 3.16.1
SpatiaLite version: 4.3.0a
target CPU: x86_64-apple-darwin15.6.0
> Inserted 100000 entities of type POINT SRID=4326
> Inserted 100000 entities of type LINESTRING SRID=4326
> Inserted 100000 entities of type POLYGON SRID=4326
$ 
$ ls -ld spatialite-test.sqlite
$ javac -classpath ".:sqlite-jdbc-3.16.1.jar" SpatialiteThreads.java 
$ java -classpath ".:sqlite-jdbc-3.16.1.jar" SpatialiteThreads
start: Slot #0    Thread #0
start: Slot #2    Thread #2
start: Slot #1    Thread #1
...
    stop: Slot #25    Thread #991
    stop: Slot #19    Thread #997
    stop: Slot #57    Thread #1000
$ 
If there is a problem with the operation of sqlite + spatialite, it seems that you should check as follows first.
$ SQLITE3_VERSION=`brew info sqlite | grep /usr/local/Cellar/sqlite | awk '{print $1}'`
$ SQLITE3=${SQLITE3_VERSION}/bin/sqlite3
$ echo $SQLITE3
$ $SQLITE3 -version
$ ( \
echo "SELECT load_extension('mod_spatialite');"  \
echo "SELECT sqlite_version();"  \
echo "SELECT spatialite_version();"  \
echo "SELECT spatialite_target_cpu();" \
) | $SQLITE3
$ 
Recommended Posts