DbUtils Class

Provides static methods used to initialize a database, copy data from one database to another, find/remove duplicates records, etc.

Constructors

There are no public constructors.

Static Methods

initSchema( Database database, String schema ) returns void
initSchema( Database database, String schema, String tableSpace ) returns boolean
Used to execute SQL statements and populate a database with table, views, triggers, etc. If the target database does not exist, an attempt is made to create a new database. Currently only supports PostgreSQL and H2.
databaseConnection info for the database
schemaString containing SQL statements. Assumes individual statements are delimited with a semicolon.
tableSpaceDefault tablespace used to store tables, views, etc. If null, will use the default database tablespace. This option only applies to PostgreSQL
getColumns( String tableName, Database sourceDB ) returns LinkedHashMap<String, Boolean>
executeBatch( ArrayList<String> statements, Connection conn ) returns void
copyTable( String tableName, String where, Database sourceDB, Database destDB, int pageSize, int numThreads ) returns void
Used to transfer records between 2 databases for a given table.
findMismatch( String tableName, Database sourceDB, Database destDB, int pageSize, long offset, AtomicLong rowID ) returns void
Used to find mismatched between the 2 databases for a given table.
deleteDuplicates( String tableName, Database database, Long startRow, Long endRow, int pageSize, int numThreads ) returns void
Used to find and delete duplicates in a given table.
getJson( Recordset rs ) returns JSONObject
Returns a JSON representation of a record in a Recordset. Column names are used as keys and the corresponding value is used as the value. Note that the column names are represented using camel case. If there are duplicate column names in the Recordset (e.g. "select user.id, contact.id from ...") the first column name and value is used (e.g. "user.id" column).
getJson( javaxt.sql.Record record ) returns JSONObject
getJson( javaxt.sql.Field[] fields ) returns JSONObject
getJson( String sql, Connection conn, boolean separateRowsAndColumns ) returns String