Package mil.nga.geopackage.io
Class SQLExec
- java.lang.Object
-
- mil.nga.geopackage.io.SQLExec
-
public class SQLExec extends Object
Executes SQL on a SQLite database To run from command line, build with the standalone profile: mvn clean install -Pstandalone java -jar name.jar +usage_arguments java -classpath name.jar mil.nga.geopackage.io.SQLExec +usage_arguments- Since:
- 3.3.0
- Author:
- osbornb
-
-
Field Summary
Fields Modifier and Type Field Description static String
ARGUMENT_BOUNDS_MANUAL
Bounds manual argumentstatic String
ARGUMENT_DGIWG
DGIWG GeoPackage Profile validation argumentstatic String
ARGUMENT_MAX_COLUMN_WIDTH
Max column width argumentstatic String
ARGUMENT_MAX_LINES_PER_ROW
Max lines per row argumentstatic String
ARGUMENT_MAX_ROWS
Max Rows argumentstatic String
ARGUMENT_PREFIX
Argument prefixstatic String
ARGUMENT_PROJECTION
Bounds projection argumentstatic String
ARGUMENT_RTREE_DROP
R-tree drop argumentstatic String
ARGUMENT_RTREE_GEODESIC
R-tree geodesic argumentstatic String
ARGUMENT_ZOOM_LEVELS
Zoom levels argumentstatic String
BLOB_DISPLAY_VALUE
Blob display valuestatic String
BLOBS_ARGUMENT_DIRECTORY
Blobs directory argumentstatic String
BLOBS_ARGUMENT_EXTENSION
Blobs extension argumentstatic String
BLOBS_ARGUMENT_PATTERN
Blobs pattern argumentstatic String
BLOBS_COLUMN_END_REGEX
Blobs column end regexstatic Pattern
BLOBS_COLUMN_PATTERN
Blobs column patternstatic int
BLOBS_COLUMN_PATTERN_GROUP
Blobs column pattern groupstatic String
BLOBS_COLUMN_START_REGEX
Blobs column start regexstatic String
BLOBS_WRITE_DEFAULT_DIRECTORY
Default write directory for blobsstatic int
COMMAND_ALL_ROWS
Command with all rowsstatic String
COMMAND_BOUNDS
GeoPackage bounds commandstatic String
COMMAND_CONTENTS
GeoPackage contents commandstatic String
COMMAND_CONTENTS_BOUNDS
GeoPackage contents bounds commandstatic String
COMMAND_COUNT
Count commandstatic String
COMMAND_DGIWG
DGIWG GeoPackage Profile validationstatic String
COMMAND_EXTENSIONS
GeoPackage extensions commandstatic String
COMMAND_FOREIGN_KEY_CHECK
SQLite Master commandstatic String
COMMAND_FOREIGN_KEYS
Foreign Keys commandstatic String
COMMAND_GEOMETRY
GeoPackage geometry commandstatic String
COMMAND_GEOPACKAGE_INFO
GeoPackage Info commandstatic String
COMMAND_HELP
Help commandstatic String
COMMAND_HISTORY
History commandstatic String
COMMAND_INDEXES
Indexes commandstatic String
COMMAND_INTEGRITY_CHECK
SQLite Master commandstatic String
COMMAND_MAX_COLUMN_WIDTH
Max column width commandstatic String
COMMAND_MAX_LINES_PER_ROW
Max lines per row commandstatic String
COMMAND_MAX_ROWS
Max rows commandstatic String
COMMAND_PREVIOUS
Previous commandstatic String
COMMAND_PROMPT
Command promptstatic String
COMMAND_QUICK_CHECK
Quick Check commandstatic String
COMMAND_REPROJECT
GeoPackage reproject commandstatic String
COMMAND_RTREE
GeoPackage R-tree commandstatic String
COMMAND_SQLITE_MASTER
SQLite Master commandstatic String
COMMAND_TABLE_BOUNDS
GeoPackage table bounds commandstatic String
COMMAND_TABLE_INFO
Table Info commandstatic String
COMMAND_TABLES
Tables commandstatic String
COMMAND_TRIGGERS
Triggers commandstatic String
COMMAND_VACUUM
VACUUM commandstatic String
COMMAND_VERSION
Version commandstatic String
COMMAND_VIEWS
Views commandstatic String
COMMAND_WRITE_BLOBS
Write blobs commandstatic Integer
DEFAULT_MAX_COLUMN_WIDTH
Default max column widthstatic Integer
DEFAULT_MAX_LINES_PER_ROW
Default max lines per rowstatic int
DEFAULT_MAX_ROWS
Default max rowsstatic Pattern
HISTORY_PATTERN
History pattern
-
Constructor Summary
Constructors Constructor Description SQLExec()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SQLExecResult
executeSQL(File databaseFile, String sql)
Execute the SQL on the databasestatic SQLExecResult
executeSQL(File databaseFile, String sql, Integer maxRows)
Execute the SQL on the databasestatic SQLExecResult
executeSQL(GeoPackage database, String sql)
Execute the SQL on the databasestatic SQLExecResult
executeSQL(GeoPackage database, String sql, Integer maxRows)
Execute the SQL on the GeoPackage databasestatic SQLExecResult
executeSQL(GeoPackage database, String sql, Projection projection, Integer maxRows)
Execute the SQL on the GeoPackage databasestatic boolean
isGeoPackage(GeoPackage database)
Check if the SQLite database is a GeoPackagestatic void
main(String[] args)
Main method to execute SQL in a SQLite database
-
-
-
Field Detail
-
ARGUMENT_PREFIX
public static final String ARGUMENT_PREFIX
Argument prefix- See Also:
- Constant Field Values
-
ARGUMENT_MAX_ROWS
public static final String ARGUMENT_MAX_ROWS
Max Rows argument- See Also:
- Constant Field Values
-
DEFAULT_MAX_ROWS
public static final int DEFAULT_MAX_ROWS
Default max rows- See Also:
- Constant Field Values
-
ARGUMENT_MAX_COLUMN_WIDTH
public static final String ARGUMENT_MAX_COLUMN_WIDTH
Max column width argument- See Also:
- Constant Field Values
-
DEFAULT_MAX_COLUMN_WIDTH
public static final Integer DEFAULT_MAX_COLUMN_WIDTH
Default max column width
-
ARGUMENT_MAX_LINES_PER_ROW
public static final String ARGUMENT_MAX_LINES_PER_ROW
Max lines per row argument- See Also:
- Constant Field Values
-
ARGUMENT_DGIWG
public static final String ARGUMENT_DGIWG
DGIWG GeoPackage Profile validation argument- See Also:
- Constant Field Values
-
DEFAULT_MAX_LINES_PER_ROW
public static final Integer DEFAULT_MAX_LINES_PER_ROW
Default max lines per row
-
HISTORY_PATTERN
public static final Pattern HISTORY_PATTERN
History pattern
-
COMMAND_PROMPT
public static final String COMMAND_PROMPT
Command prompt- See Also:
- Constant Field Values
-
COMMAND_HELP
public static final String COMMAND_HELP
Help command- See Also:
- Constant Field Values
-
COMMAND_VERSION
public static final String COMMAND_VERSION
Version command- See Also:
- Constant Field Values
-
COMMAND_TABLES
public static final String COMMAND_TABLES
Tables command- See Also:
- Constant Field Values
-
COMMAND_INDEXES
public static final String COMMAND_INDEXES
Indexes command- See Also:
- Constant Field Values
-
COMMAND_VIEWS
public static final String COMMAND_VIEWS
Views command- See Also:
- Constant Field Values
-
COMMAND_TRIGGERS
public static final String COMMAND_TRIGGERS
Triggers command- See Also:
- Constant Field Values
-
COMMAND_ALL_ROWS
public static final int COMMAND_ALL_ROWS
Command with all rows- See Also:
- Constant Field Values
-
COMMAND_HISTORY
public static final String COMMAND_HISTORY
History command- See Also:
- Constant Field Values
-
COMMAND_PREVIOUS
public static final String COMMAND_PREVIOUS
Previous command- See Also:
- Constant Field Values
-
COMMAND_WRITE_BLOBS
public static final String COMMAND_WRITE_BLOBS
Write blobs command- See Also:
- Constant Field Values
-
COMMAND_MAX_ROWS
public static final String COMMAND_MAX_ROWS
Max rows command- See Also:
- Constant Field Values
-
COMMAND_MAX_COLUMN_WIDTH
public static final String COMMAND_MAX_COLUMN_WIDTH
Max column width command- See Also:
- Constant Field Values
-
COMMAND_MAX_LINES_PER_ROW
public static final String COMMAND_MAX_LINES_PER_ROW
Max lines per row command- See Also:
- Constant Field Values
-
COMMAND_TABLE_INFO
public static final String COMMAND_TABLE_INFO
Table Info command- See Also:
- Constant Field Values
-
COMMAND_COUNT
public static final String COMMAND_COUNT
Count command- See Also:
- Constant Field Values
-
COMMAND_VACUUM
public static final String COMMAND_VACUUM
VACUUM command- See Also:
- Constant Field Values
-
COMMAND_FOREIGN_KEYS
public static final String COMMAND_FOREIGN_KEYS
Foreign Keys command- See Also:
- Constant Field Values
-
COMMAND_FOREIGN_KEY_CHECK
public static final String COMMAND_FOREIGN_KEY_CHECK
SQLite Master command- See Also:
- Constant Field Values
-
COMMAND_INTEGRITY_CHECK
public static final String COMMAND_INTEGRITY_CHECK
SQLite Master command- See Also:
- Constant Field Values
-
COMMAND_QUICK_CHECK
public static final String COMMAND_QUICK_CHECK
Quick Check command- See Also:
- Constant Field Values
-
COMMAND_SQLITE_MASTER
public static final String COMMAND_SQLITE_MASTER
SQLite Master command- See Also:
- Constant Field Values
-
COMMAND_CONTENTS
public static final String COMMAND_CONTENTS
GeoPackage contents command- See Also:
- Constant Field Values
-
COMMAND_GEOPACKAGE_INFO
public static final String COMMAND_GEOPACKAGE_INFO
GeoPackage Info command- See Also:
- Constant Field Values
-
COMMAND_EXTENSIONS
public static final String COMMAND_EXTENSIONS
GeoPackage extensions command- See Also:
- Constant Field Values
-
COMMAND_RTREE
public static final String COMMAND_RTREE
GeoPackage R-tree command- See Also:
- Constant Field Values
-
COMMAND_GEOMETRY
public static final String COMMAND_GEOMETRY
GeoPackage geometry command- See Also:
- Constant Field Values
-
COMMAND_REPROJECT
public static final String COMMAND_REPROJECT
GeoPackage reproject command- See Also:
- Constant Field Values
-
COMMAND_DGIWG
public static final String COMMAND_DGIWG
DGIWG GeoPackage Profile validation- See Also:
- Constant Field Values
-
BLOB_DISPLAY_VALUE
public static final String BLOB_DISPLAY_VALUE
Blob display value- See Also:
- Constant Field Values
-
BLOBS_WRITE_DEFAULT_DIRECTORY
public static final String BLOBS_WRITE_DEFAULT_DIRECTORY
Default write directory for blobs- See Also:
- Constant Field Values
-
BLOBS_ARGUMENT_EXTENSION
public static final String BLOBS_ARGUMENT_EXTENSION
Blobs extension argument- See Also:
- Constant Field Values
-
BLOBS_ARGUMENT_DIRECTORY
public static final String BLOBS_ARGUMENT_DIRECTORY
Blobs directory argument- See Also:
- Constant Field Values
-
BLOBS_ARGUMENT_PATTERN
public static final String BLOBS_ARGUMENT_PATTERN
Blobs pattern argument- See Also:
- Constant Field Values
-
BLOBS_COLUMN_START_REGEX
public static final String BLOBS_COLUMN_START_REGEX
Blobs column start regex- See Also:
- Constant Field Values
-
BLOBS_COLUMN_END_REGEX
public static final String BLOBS_COLUMN_END_REGEX
Blobs column end regex- See Also:
- Constant Field Values
-
COMMAND_CONTENTS_BOUNDS
public static final String COMMAND_CONTENTS_BOUNDS
GeoPackage contents bounds command- See Also:
- Constant Field Values
-
COMMAND_BOUNDS
public static final String COMMAND_BOUNDS
GeoPackage bounds command- See Also:
- Constant Field Values
-
COMMAND_TABLE_BOUNDS
public static final String COMMAND_TABLE_BOUNDS
GeoPackage table bounds command- See Also:
- Constant Field Values
-
ARGUMENT_PROJECTION
public static final String ARGUMENT_PROJECTION
Bounds projection argument- See Also:
- Constant Field Values
-
ARGUMENT_ZOOM_LEVELS
public static final String ARGUMENT_ZOOM_LEVELS
Zoom levels argument- See Also:
- Constant Field Values
-
ARGUMENT_BOUNDS_MANUAL
public static final String ARGUMENT_BOUNDS_MANUAL
Bounds manual argument- See Also:
- Constant Field Values
-
ARGUMENT_RTREE_GEODESIC
public static final String ARGUMENT_RTREE_GEODESIC
R-tree geodesic argument- See Also:
- Constant Field Values
-
ARGUMENT_RTREE_DROP
public static final String ARGUMENT_RTREE_DROP
R-tree drop argument- See Also:
- Constant Field Values
-
BLOBS_COLUMN_PATTERN
public static final Pattern BLOBS_COLUMN_PATTERN
Blobs column pattern
-
BLOBS_COLUMN_PATTERN_GROUP
public static final int BLOBS_COLUMN_PATTERN_GROUP
Blobs column pattern group- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(String[] args) throws Exception
Main method to execute SQL in a SQLite database- Parameters:
args
- arguments- Throws:
Exception
- upon failure
-
executeSQL
public static SQLExecResult executeSQL(File databaseFile, String sql) throws SQLException
Execute the SQL on the database- Parameters:
databaseFile
- database filesql
- SQL statement- Returns:
- results
- Throws:
SQLException
- upon SQL error
-
executeSQL
public static SQLExecResult executeSQL(File databaseFile, String sql, Integer maxRows) throws SQLException
Execute the SQL on the database- Parameters:
databaseFile
- database filesql
- SQL statementmaxRows
- max rows- Returns:
- results
- Throws:
SQLException
- upon SQL error
-
executeSQL
public static SQLExecResult executeSQL(GeoPackage database, String sql) throws SQLException
Execute the SQL on the database- Parameters:
database
- open databasesql
- SQL statement- Returns:
- results
- Throws:
SQLException
- upon SQL error
-
executeSQL
public static SQLExecResult executeSQL(GeoPackage database, String sql, Integer maxRows) throws SQLException
Execute the SQL on the GeoPackage database- Parameters:
database
- open databasesql
- SQL statementmaxRows
- max rows- Returns:
- results
- Throws:
SQLException
- upon SQL error
-
executeSQL
public static SQLExecResult executeSQL(GeoPackage database, String sql, Projection projection, Integer maxRows) throws SQLException
Execute the SQL on the GeoPackage database- Parameters:
database
- open databasesql
- SQL statementprojection
- desired projectionmaxRows
- max rows- Returns:
- results
- Throws:
SQLException
- upon SQL error
-
isGeoPackage
public static boolean isGeoPackage(GeoPackage database)
Check if the SQLite database is a GeoPackage- Parameters:
database
- SQLite database- Returns:
- true if a GeoPackage
-
-