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 StringARGUMENT_BOUNDS_MANUALBounds manual argumentstatic StringARGUMENT_DGIWGDGIWG GeoPackage Profile validation argumentstatic StringARGUMENT_MAX_COLUMN_WIDTHMax column width argumentstatic StringARGUMENT_MAX_LINES_PER_ROWMax lines per row argumentstatic StringARGUMENT_MAX_ROWSMax Rows argumentstatic StringARGUMENT_PREFIXArgument prefixstatic StringARGUMENT_PROJECTIONBounds projection argumentstatic StringARGUMENT_RTREE_DROPR-tree drop argumentstatic StringARGUMENT_RTREE_GEODESICR-tree geodesic argumentstatic StringARGUMENT_ZOOM_LEVELSZoom levels argumentstatic StringBLOB_DISPLAY_VALUEBlob display valuestatic StringBLOBS_ARGUMENT_DIRECTORYBlobs directory argumentstatic StringBLOBS_ARGUMENT_EXTENSIONBlobs extension argumentstatic StringBLOBS_ARGUMENT_PATTERNBlobs pattern argumentstatic StringBLOBS_COLUMN_END_REGEXBlobs column end regexstatic PatternBLOBS_COLUMN_PATTERNBlobs column patternstatic intBLOBS_COLUMN_PATTERN_GROUPBlobs column pattern groupstatic StringBLOBS_COLUMN_START_REGEXBlobs column start regexstatic StringBLOBS_WRITE_DEFAULT_DIRECTORYDefault write directory for blobsstatic intCOMMAND_ALL_ROWSCommand with all rowsstatic StringCOMMAND_BOUNDSGeoPackage bounds commandstatic StringCOMMAND_CONTENTSGeoPackage contents commandstatic StringCOMMAND_CONTENTS_BOUNDSGeoPackage contents bounds commandstatic StringCOMMAND_COUNTCount commandstatic StringCOMMAND_DGIWGDGIWG GeoPackage Profile validationstatic StringCOMMAND_EXTENSIONSGeoPackage extensions commandstatic StringCOMMAND_FOREIGN_KEY_CHECKSQLite Master commandstatic StringCOMMAND_FOREIGN_KEYSForeign Keys commandstatic StringCOMMAND_GEOMETRYGeoPackage geometry commandstatic StringCOMMAND_GEOPACKAGE_INFOGeoPackage Info commandstatic StringCOMMAND_HELPHelp commandstatic StringCOMMAND_HISTORYHistory commandstatic StringCOMMAND_INDEXESIndexes commandstatic StringCOMMAND_INTEGRITY_CHECKSQLite Master commandstatic StringCOMMAND_MAX_COLUMN_WIDTHMax column width commandstatic StringCOMMAND_MAX_LINES_PER_ROWMax lines per row commandstatic StringCOMMAND_MAX_ROWSMax rows commandstatic StringCOMMAND_PREVIOUSPrevious commandstatic StringCOMMAND_PROMPTCommand promptstatic StringCOMMAND_QUICK_CHECKQuick Check commandstatic StringCOMMAND_REPROJECTGeoPackage reproject commandstatic StringCOMMAND_RTREEGeoPackage R-tree commandstatic StringCOMMAND_SQLITE_MASTERSQLite Master commandstatic StringCOMMAND_TABLE_BOUNDSGeoPackage table bounds commandstatic StringCOMMAND_TABLE_INFOTable Info commandstatic StringCOMMAND_TABLESTables commandstatic StringCOMMAND_TRIGGERSTriggers commandstatic StringCOMMAND_VACUUMVACUUM commandstatic StringCOMMAND_VERSIONVersion commandstatic StringCOMMAND_VIEWSViews commandstatic StringCOMMAND_WRITE_BLOBSWrite blobs commandstatic IntegerDEFAULT_MAX_COLUMN_WIDTHDefault max column widthstatic IntegerDEFAULT_MAX_LINES_PER_ROWDefault max lines per rowstatic intDEFAULT_MAX_ROWSDefault max rowsstatic PatternHISTORY_PATTERNHistory pattern
-
Constructor Summary
Constructors Constructor Description SQLExec()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SQLExecResultexecuteSQL(File databaseFile, String sql)Execute the SQL on the databasestatic SQLExecResultexecuteSQL(File databaseFile, String sql, Integer maxRows)Execute the SQL on the databasestatic SQLExecResultexecuteSQL(GeoPackage database, String sql)Execute the SQL on the databasestatic SQLExecResultexecuteSQL(GeoPackage database, String sql, Integer maxRows)Execute the SQL on the GeoPackage databasestatic SQLExecResultexecuteSQL(GeoPackage database, String sql, Projection projection, Integer maxRows)Execute the SQL on the GeoPackage databasestatic booleanisGeoPackage(GeoPackage database)Check if the SQLite database is a GeoPackagestatic voidmain(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
-
-