Class SystemProcedures
- java.lang.Object
-
- org.apache.derby.catalog.SystemProcedures
-
public class SystemProcedures extends java.lang.Object
Some system built-in procedures, and help routines. Now used for network server. These procedures are built-in to the SYSIBM schema which match the DB2 SYSIBM procedures. Currently information on those can be found at url: ftp://ftp.software.ibm.com/ps/products/db2/info/vr8/pdf/letter/db2l2e80.pdfAlso used for builtin-routines, such as SYSFUN functions, when direct calls into Java libraries cannot be made.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DRIVER_TYPE_OPTION
private static java.lang.String
ODBC_DRIVER_OPTION
private static int
SQL_BEST_ROWID
private static int
SQL_ROWVER
-
Constructor Summary
Constructors Constructor Description SystemProcedures()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addUser(java.lang.String userName, java.lang.String password, TransactionController tc)
Create a new user (this entry is called when bootstrapping the credentials of the DBO at database creation time.private static java.lang.String
basicSchemaTableValidation(java.lang.String schemaname, java.lang.String tablename)
Do following checks a)Schema name can't be empty string b)If schema name is null, then we use current schema c)Table name can't be null or empty stringprivate static void
checkJarSQLName(java.lang.String sqlName)
private static void
checkLegalUser(DataDictionary dd, java.lang.String userName)
Raise an exception if the user doesn't exist.static double
COT(double value)
Cotangent function.private static void
createXplainSchema(java.lang.String schemaName)
private static void
createXplainTable(LanguageConnectionContext lcc, java.lang.String schemaName, XPLAINTableDescriptor t)
private static java.sql.Connection
getDefaultConn()
Get the default or nested connection corresponding to the URL jdbc:default:connection.private static java.sql.DatabaseMetaData
getDMD()
Get the DatabaseMetaData for the current connection for use in mapping the jcc SYSIBM.* calls to the Derby DatabaseMetaData methodsprivate static ModuleFactory
getMonitor()
Helper routine which looks up the monitor.private static java.lang.String
getOption(java.lang.String pattern, java.lang.String options)
Helper for SQLForeignKeys and SQLTablesprivate static java.lang.String
getProperty(java.lang.String key, Securable authorizationCheck)
This method exists so that we can get a property value without performing authorization checks.private static boolean
hasSchema(java.sql.Connection conn, java.lang.String schemaName)
private static boolean
hasTable(java.sql.Connection conn, java.lang.String schemaName, java.lang.String tableName)
static void
INSTALL_JAR(java.lang.String url, java.lang.String jar, int deploy)
Install a jar file in the database.private static boolean
isForODBC(java.lang.String options)
Helper for ODBC metadata calls.private static UserDescriptor
makeUserDescriptor(DataDictionary dd, TransactionController tc, java.lang.String userName, java.lang.String password)
static void
METADATA(java.sql.ResultSet[] rs)
private static java.lang.String
normalizeUserName(java.lang.String userName)
Normalize the user name so that there is only one set of credentials for a given authorization id.static double
PI()
Method to return the constant PI.static double
RAND(int seed)
Pseudo-random number function.static void
REMOVE_JAR(java.lang.String jar, int undeploy)
Remove a jar file from the database.private static void
removeFromAccessList(java.lang.String listProperty, java.lang.String userName)
Utility method for SYSCS_SET_USER_ACCESS removes a user from one of the access lists, driven by the property name.static void
REPLACE_JAR(java.lang.String url, java.lang.String jar)
Replace a jar file in the database.private static void
resetAuthorizationIDPassword(java.lang.String userName, java.lang.String password)
Reset the password for an already normalized authorization id.private static void
rollBackAndThrowSQLException(java.sql.Connection conn, java.sql.SQLException se)
issue a rollback when SQLException se occurs.private static void
setDatabaseProperty(java.lang.String key, java.lang.String value, Securable authorizationCheck)
static int
SIGN(double value)
Method to return the sign of the given value.static void
SQLCAMESSAGE(int sqlcode, short errmcLen, java.lang.String sqlerrmc, java.lang.String sqlerrp, int errd0, int errd1, int errd2, int errd3, int errd4, int errd5, java.lang.String warn, java.lang.String sqlState, java.lang.String file, java.lang.String localeStr, java.lang.String[] msg, int[] rc)
Method used by Derby Network Server to get localized message (original call from jcc.static void
SQLCOLPRIVILEGES(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String columnName, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLColPrivileges to EmbedDatabaseMetaData.getColumnPrivilegesstatic void
SQLCOLUMNS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String columnName, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLColumns to EmbedDatabaseMetaData.getColumnsstatic void
SQLFOREIGNKEYS(java.lang.String pkCatalogName, java.lang.String pkSchemaName, java.lang.String pkTableName, java.lang.String fkCatalogName, java.lang.String fkSchemaName, java.lang.String fkTableName, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLForeignKeys to EmbedDatabaseMetaData.getImportedKeys, getExportedKeys, and getCrossReferencestatic void
SQLFUNCTIONPARAMS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String funcName, java.lang.String paramName, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLFunctionParameters to EmbedDatabaseMetaData.getFunctionColumns()static void
SQLFUNCTIONS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String funcName, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLFunctions to EmbedDatabaseMetaData.getFunctionsstatic void
SQLGETTYPEINFO(short dataType, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLGetTypeInfo to EmbedDatabaseMetaData.getTypeInfostatic void
SQLPRIMARYKEYS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLPrimaryKeys to EmbedDatabaseMetaData.getPrimaryKeysstatic void
SQLPROCEDURECOLS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String procName, java.lang.String paramName, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLProcedureCols to EmbedDatabaseMetaData.getProcedureColumnsstatic void
SQLPROCEDURES(java.lang.String catalogName, java.lang.String schemaName, java.lang.String procName, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLProcedures to EmbedDatabaseMetaData.getProceduresstatic void
SQLSPECIALCOLUMNS(short colType, java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, short scope, short nullable, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLSpecialColumns to EmbedDatabaseMetaData.getBestRowIdentifier and getVersionColumnsstatic void
SQLSTATISTICS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, short unique, short approximate, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLStatistics to EmbedDatabaseMetaData.getIndexInfostatic void
SQLTABLEPRIVILEGES(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLTablePrivileges to EmbedDatabaseMetaData.getTablePrivilegesstatic void
SQLTABLES(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String tableType, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLTables to EmbedDatabaseMetaData.getSchemas, getCatalogs, getTableTypes and getTables, and return the result of the DatabaseMetaData calls.static void
SQLUDTS(java.lang.String catalogName, java.lang.String schemaPattern, java.lang.String typeNamePattern, java.lang.String udtTypes, java.lang.String options, java.sql.ResultSet[] rs)
Map SQLUDTS to EmbedDatabaseMetaData.getUDTsstatic void
SYSCS_BACKUP_DATABASE(java.lang.String backupDir)
Backup the database to a backup directory.static void
SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(java.lang.String backupDir, short deleteOnlineArchivedLogFiles)
Backup the database to a backup directory and enable the log archive mode that will keep the archived log files required for roll-forward from this version of the backup.static void
SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(java.lang.String backupDir, short deleteOnlineArchivedLogFiles)
Backup the database to a backup directory and enable the log archive mode that will keep the archived log files required for roll-forward from this version backup.static void
SYSCS_BACKUP_DATABASE_NOWAIT(java.lang.String backupDir)
Backup the database to a backup directory.static void
SYSCS_BULK_INSERT(java.lang.String schemaName, java.lang.String tableName, java.lang.String vtiName, java.lang.String vtiArg)
Perform bulk insert using the specificed vti .static int
SYSCS_CHECK_TABLE(java.lang.String schema, java.lang.String tablename)
static void
SYSCS_CHECKPOINT_DATABASE()
static void
SYSCS_COMPRESS_TABLE(java.lang.String schemaname, java.lang.String tablename, short sequential)
Compress the table.static void
SYSCS_CREATE_USER(java.lang.String userName, java.lang.String password)
Create a new user.static void
SYSCS_DISABLE_LOG_ARCHIVE_MODE(short deleteOnlineArchivedLogFiles)
Disables the log archival process, i.e No old log files will be kept around for a roll-forward recovery.static void
SYSCS_DROP_STATISTICS(java.lang.String schemaname, java.lang.String tablename, java.lang.String indexname)
Drop the statistics for 1)all the indexes or 2)a specific index on a table.static void
SYSCS_DROP_USER(java.lang.String userName)
Drop a user.static void
SYSCS_EMPTY_STATEMENT_CACHE()
Empty as much of the cache as possible.static void
SYSCS_EXPORT_QUERY(java.lang.String selectStatement, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset)
Export data from a select statement to given file.static void
SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE(java.lang.String selectStatement, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, java.lang.String lobsFileName)
Export data from a select statement to given file.static void
SYSCS_EXPORT_TABLE(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset)
Export data from a table to given file.static void
SYSCS_EXPORT_TABLE_LOBS_TO_EXTFILE(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, java.lang.String lobsFileName)
Export data from a table to given files.static void
SYSCS_FREEZE_DATABASE()
Freeze the database.static java.lang.String
SYSCS_GET_DATABASE_NAME()
Return the database namestatic java.lang.String
SYSCS_GET_DATABASE_PROPERTY(java.lang.String key)
Get the value of a property of the database in current connection.static java.lang.String
SYSCS_GET_RUNTIMESTATISTICS()
static java.lang.String
SYSCS_GET_USER_ACCESS(java.lang.String userName)
Get the connection level authorization for a specific user - SYSCS_UTIL.SYSCS_GET_USER_ACCESS.static int
SYSCS_GET_XPLAIN_MODE()
This procedure returns the current status of the xplain mode.static java.lang.String
SYSCS_GET_XPLAIN_SCHEMA()
This procedure returns the current set XPLAIN_SCHEMAstatic void
SYSCS_IMPORT_DATA(java.lang.String schemaName, java.lang.String tableName, java.lang.String insertColumnList, java.lang.String columnIndexes, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace)
Import data from a given file into the specified table columns from the specified columns in the file.static void
SYSCS_IMPORT_DATA_BULK(java.lang.String schemaName, java.lang.String tableName, java.lang.String insertColumnList, java.lang.String columnIndexes, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace, short skip)
Import data from a given file into the specified table columns skipping header lines from the specified columns in the file.static void
SYSCS_IMPORT_DATA_LOBS_FROM_EXTFILE(java.lang.String schemaName, java.lang.String tableName, java.lang.String insertColumnList, java.lang.String columnIndexes, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace)
Import data from a given file into the specified table columns from the specified columns in the file.static void
SYSCS_IMPORT_TABLE(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace)
Import data from a given file to a table.static void
SYSCS_IMPORT_TABLE_BULK(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace, short skip)
static void
SYSCS_IMPORT_TABLE_LOBS_FROM_EXTFILE(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace)
Import data from a given file to a table.static void
SYSCS_INPLACE_COMPRESS_TABLE(java.lang.String schema, java.lang.String tablename, short purgeRows, short defragmentRows, short truncateEnd)
Implementation of SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE().static void
SYSCS_INVALIDATE_STORED_STATEMENTS()
Invalidate all the stored statements so they will get recompiled when executed next time around.static void
SYSCS_MODIFY_PASSWORD(java.lang.String password)
Change a user's password.static java.lang.Long
SYSCS_PEEK_AT_IDENTITY(java.lang.String schemaName, java.lang.String tableName)
Peek at the current value of an identity generator without advancing it.static java.lang.Long
SYSCS_PEEK_AT_SEQUENCE(java.lang.String schemaName, java.lang.String sequenceName)
Peek at the current value of a sequence generator without advancing it.static void
SYSCS_RELOAD_SECURITY_POLICY()
Reload the policy file.static void
SYSCS_RESET_PASSWORD(java.lang.String userName, java.lang.String password)
Reset a user's password.static void
SYSCS_SET_DATABASE_PROPERTY(java.lang.String key, java.lang.String value)
Set/delete the value of a property of the database in current connection.static void
SYSCS_SET_RUNTIMESTATISTICS(short enable)
static void
SYSCS_SET_STATISTICS_TIMING(short enable)
static void
SYSCS_SET_USER_ACCESS(java.lang.String userName, java.lang.String connectionPermission)
Set the connection level authorization for a specific user - SYSCS_UTIL.SYSCS_SET_USER_ACCESS.static void
SYSCS_SET_XPLAIN_MODE(int mode)
this procedure switches between the different xplain modesstatic void
SYSCS_SET_XPLAIN_SCHEMA(java.lang.String schemaName)
This procedure sets the current xplain schema.static void
SYSCS_UNFREEZE_DATABASE()
Unfreeze the database.static void
SYSCS_UPDATE_STATISTICS(java.lang.String schemaname, java.lang.String tablename, java.lang.String indexname)
Update the statistics for 1)all the indexes or 2)a specific index on a table.
-
-
-
Field Detail
-
SQL_BEST_ROWID
private static final int SQL_BEST_ROWID
- See Also:
- Constant Field Values
-
SQL_ROWVER
private static final int SQL_ROWVER
- See Also:
- Constant Field Values
-
DRIVER_TYPE_OPTION
private static final java.lang.String DRIVER_TYPE_OPTION
- See Also:
- Constant Field Values
-
ODBC_DRIVER_OPTION
private static final java.lang.String ODBC_DRIVER_OPTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
SQLCAMESSAGE
public static void SQLCAMESSAGE(int sqlcode, short errmcLen, java.lang.String sqlerrmc, java.lang.String sqlerrp, int errd0, int errd1, int errd2, int errd3, int errd4, int errd5, java.lang.String warn, java.lang.String sqlState, java.lang.String file, java.lang.String localeStr, java.lang.String[] msg, int[] rc)
Method used by Derby Network Server to get localized message (original call from jcc.- Parameters:
sqlcode
- sqlcode, not used.errmcLen
- sqlerrmc lengthsqlerrmc
- sql error message tokens, variable part of error message (ie., arguments) plus messageId, separated by separator.sqlerrp
- not usederrd0
- not usederrd1
- not usederrd2
- not usederrd3
- not usederrd4
- not usederrd5
- not usedwarn
- not usedsqlState
- 5-char sql statefile
- not usedlocaleStr
- client locale in stringmsg
- OUTPUT parameter, localized error messagerc
- OUTPUT parameter, return code -- 0 for success
-
getDefaultConn
private static java.sql.Connection getDefaultConn() throws java.sql.SQLException
Get the default or nested connection corresponding to the URL jdbc:default:connection. We do not use DriverManager here as it is not supported in JSR 169. IN addition we need to perform more checks for null drivers or the driver returing null from connect as that logic is in DriverManager.- Returns:
- The nested connection
- Throws:
java.sql.SQLException
- Not running in a SQL statement
-
getDMD
private static java.sql.DatabaseMetaData getDMD() throws java.sql.SQLException
Get the DatabaseMetaData for the current connection for use in mapping the jcc SYSIBM.* calls to the Derby DatabaseMetaData methods- Returns:
- The DatabaseMetaData object of the current connection
- Throws:
java.sql.SQLException
-
SQLPROCEDURES
public static void SQLPROCEDURES(java.lang.String catalogName, java.lang.String schemaName, java.lang.String procName, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLProcedures to EmbedDatabaseMetaData.getProcedures- Parameters:
catalogName
- SYSIBM.SQLProcedures CatalogName varchar(128),schemaName
- SYSIBM.SQLProcedures SchemaName varchar(128),procName
- SYSIBM.SQLProcedures ProcName varchar(128),options
- SYSIBM.SQLProcedures Options varchar(4000))rs
- output parameter, the resultset object containing the result of getProcedures If options contains the string 'DATATYPE='ODBC'', call the ODBC version of this procedure.- Throws:
java.sql.SQLException
-
SQLFUNCTIONS
public static void SQLFUNCTIONS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String funcName, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLFunctions to EmbedDatabaseMetaData.getFunctions- Parameters:
catalogName
- SYSIBM.SQLFunctions CatalogName varchar(128),schemaName
- SYSIBM.SQLFunctions SchemaName varchar(128),funcName
- SYSIBM.SQLFunctions ProcName varchar(128),options
- SYSIBM.SQLFunctions Options varchar(4000)) (not used)rs
- output parameter, the resultset object containing the result of getFunctions- Throws:
java.sql.SQLException
-
SQLTABLES
public static void SQLTABLES(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String tableType, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLTables to EmbedDatabaseMetaData.getSchemas, getCatalogs, getTableTypes and getTables, and return the result of the DatabaseMetaData calls.JCC and DNC overload this method:
- If options contains the string 'GETSCHEMAS=1', call getSchemas()
- If options contains the string 'GETSCHEMAS=2', call getSchemas(String, String)
- If options contains the string 'GETCATALOGS=1', call getCatalogs()
- If options contains the string 'GETTABLETYPES=1', call getTableTypes()
- otherwise, call getTables()
- Parameters:
catalogName
- SYSIBM.SQLTables CatalogName varchar(128),schemaName
- SYSIBM.SQLTables SchemaName varchar(128),tableName
- SYSIBM.SQLTables TableName varchar(128),tableType
- SYSIBM.SQLTables TableType varchar(4000))options
- SYSIBM.SQLTables Options varchar(4000))rs
- output parameter, the resultset object- Throws:
java.sql.SQLException
-
SQLFOREIGNKEYS
public static void SQLFOREIGNKEYS(java.lang.String pkCatalogName, java.lang.String pkSchemaName, java.lang.String pkTableName, java.lang.String fkCatalogName, java.lang.String fkSchemaName, java.lang.String fkTableName, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLForeignKeys to EmbedDatabaseMetaData.getImportedKeys, getExportedKeys, and getCrossReference- Parameters:
pkCatalogName
- SYSIBM.SQLForeignKeys PKCatalogName varchar(128),pkSchemaName
- SYSIBM.SQLForeignKeys PKSchemaName varchar(128),pkTableName
- SYSIBM.SQLForeignKeys PKTableName varchar(128),fkCatalogName
- SYSIBM.SQLForeignKeys FKCatalogName varchar(128),fkSchemaName
- SYSIBM.SQLForeignKeys FKSchemaName varchar(128),fkTableName
- SYSIBM.SQLForeignKeys FKTableName varchar(128),options
- SYSIBM.SQLForeignKeys Options varchar(4000))rs
- output parameter, the resultset object containing the result of the DatabaseMetaData calls JCC overloads this method: If options contains the string 'EXPORTEDKEY=1', call getImportedKeys If options contains the string 'IMPORTEDKEY=1', call getExportedKeys otherwise, call getCrossReference- Throws:
java.sql.SQLException
-
getOption
private static java.lang.String getOption(java.lang.String pattern, java.lang.String options)
Helper for SQLForeignKeys and SQLTables- Parameters:
pattern
- String containing the option to search foroptions
- String containing the options to search through- Returns:
- option String containing the value for a given option
-
SQLPROCEDURECOLS
public static void SQLPROCEDURECOLS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String procName, java.lang.String paramName, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLProcedureCols to EmbedDatabaseMetaData.getProcedureColumns- Parameters:
catalogName
- SYSIBM.SQLProcedureCols CatalogName varchar(128),schemaName
- SYSIBM.SQLProcedureCols SchemaName varchar(128),procName
- SYSIBM.SQLProcedureCols ProcName varchar(128),paramName
- SYSIBM.SQLProcedureCols ParamName varchar(128),options
- SYSIBM.SQLProcedureCols Options varchar(4000))rs
- output parameter, the resultset object containing the result of getProcedureColumns If options contains the string 'DATATYPE='ODBC'', call the ODBC version of this procedure.- Throws:
java.sql.SQLException
-
SQLFUNCTIONPARAMS
public static void SQLFUNCTIONPARAMS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String funcName, java.lang.String paramName, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLFunctionParameters to EmbedDatabaseMetaData.getFunctionColumns()- Parameters:
catalogName
- SYSIBM.SQLFunctionParameters CatalogName varchar(128),schemaName
- SYSIBM.SQLFunctionParameters SchemaName varchar(128),funcName
- SYSIBM.SQLFunctionParameters FuncName varchar(128),paramName
- SYSIBM.SQLFunctionParameters ParamName varchar(128),options
- SYSIBM.SQLFunctionParameters Options varchar(4000))rs
- output parameter, the resultset object containing the result of getFunctionColumns().- Throws:
java.sql.SQLException
-
SQLCOLUMNS
public static void SQLCOLUMNS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String columnName, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLColumns to EmbedDatabaseMetaData.getColumns- Parameters:
catalogName
- SYSIBM.SQLColumns CatalogName varchar(128),schemaName
- SYSIBM.SQLColumns SchemaName varchar(128),tableName
- SYSIBM.SQLColumns TableName varchar(128),columnName
- SYSIBM.SQLColumns ColumnName varchar(128),options
- SYSIBM.SQLColumns Options varchar(4000)) If options contains the string 'DATATYPE='ODBC'', call the ODBC version of this procedure.rs
- output parameter, the resultset object containing the result of getProcedures- Throws:
java.sql.SQLException
-
SQLCOLPRIVILEGES
public static void SQLCOLPRIVILEGES(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String columnName, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLColPrivileges to EmbedDatabaseMetaData.getColumnPrivileges- Parameters:
catalogName
- SYSIBM.SQLColPrivileges CatalogName varchar(128),schemaName
- SYSIBM.SQLColPrivileges SchemaName varchar(128),tableName
- SYSIBM.SQLColPrivileges ProcName varchar(128),columnName
- SYSIBM.SQLColPrivileges ColumnName varchar(128),options
- SYSIBM.SQLColPrivileges Options varchar(4000))rs
- output parameter, the resultset object containing the result of getColumnPrivileges- Throws:
java.sql.SQLException
-
SQLTABLEPRIVILEGES
public static void SQLTABLEPRIVILEGES(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLTablePrivileges to EmbedDatabaseMetaData.getTablePrivileges- Parameters:
catalogName
- SYSIBM.SQLTablePrivileges CatalogName varchar(128),schemaName
- SYSIBM.SQLTablePrivileges SchemaName varchar(128),tableName
- SYSIBM.SQLTablePrivileges ProcName varchar(128),options
- SYSIBM.SQLTablePrivileges Options varchar(4000))rs
- output parameter, the resultset object containing the result of getTablePrivileges- Throws:
java.sql.SQLException
-
SQLPRIMARYKEYS
public static void SQLPRIMARYKEYS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLPrimaryKeys to EmbedDatabaseMetaData.getPrimaryKeys- Parameters:
catalogName
- SYSIBM.SQLPrimaryKeys CatalogName varchar(128),schemaName
- SYSIBM.SQLPrimaryKeys SchemaName varchar(128),tableName
- SYSIBM.SQLPrimaryKeys TableName varchar(128),options
- SYSIBM.SQLPrimaryKeys Options varchar(4000)) If options contains the string 'DATATYPE='ODBC'', call the ODBC version of this procedure.rs
- output parameter, the resultset object containing the result of getPrimaryKeys- Throws:
java.sql.SQLException
-
SQLGETTYPEINFO
public static void SQLGETTYPEINFO(short dataType, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLGetTypeInfo to EmbedDatabaseMetaData.getTypeInfo- Parameters:
dataType
- SYSIBM.SQLGetTypeInfo DataType smallint,options
- SYSIBM.SQLGetTypeInfo Options varchar(4000)) If options contains the string 'DATATYPE='ODBC'', call the ODBC version of this procedure.rs
- output parameter, the resultset object containing the result of getTypeInfo- Throws:
java.sql.SQLException
-
SQLSTATISTICS
public static void SQLSTATISTICS(java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, short unique, short approximate, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLStatistics to EmbedDatabaseMetaData.getIndexInfo- Parameters:
catalogName
- SYSIBM.SQLStatistics CatalogName varchar(128),schemaName
- SYSIBM.SQLStatistics SchemaName varchar(128),tableName
- SYSIBM.SQLStatistics TableName varchar(128),unique
- SYSIBM.SQLStatistics Unique smallint; 0=SQL_INDEX_UNIQUE(0); 1=SQL_INDEX_ALL(1),approximate
- SYSIBM.SQLStatistics Approximate smallint; 1=true; 0=false,options
- SYSIBM.SQLStatistics Options varchar(4000)) If options contains the string 'DATATYPE='ODBC'', call the ODBC version of this procedure.rs
- output parameter, the resultset object containing the result of getIndexInfo- Throws:
java.sql.SQLException
-
SQLSPECIALCOLUMNS
public static void SQLSPECIALCOLUMNS(short colType, java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName, short scope, short nullable, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLSpecialColumns to EmbedDatabaseMetaData.getBestRowIdentifier and getVersionColumns- Parameters:
colType
- SYSIBM.SQLSpecialColumns ColType smallint, where 1 means getBestRowIdentifier and 2 getVersionColumns was called.catalogName
- SYSIBM.SQLSpecialColumns CatalogName varchar(128),schemaName
- SYSIBM.SQLSpecialColumns SchemaName varchar(128),tableName
- SYSIBM.SQLSpecialColumns TableName varchar(128),scope
- SYSIBM.SQLSpecialColumns Scope smallint,nullable
- SYSIBM.SQLSpecialColumns Nullable smallint; 0=false, 1=true,options
- SYSIBM.SQLSpecialColumns Options varchar(4000)) If options contains the string 'DATATYPE='ODBC'', call the ODBC version of this procedure.rs
- output parameter, the resultset object containing the result of the DatabaseMetaData call- Throws:
java.sql.SQLException
-
SQLUDTS
public static void SQLUDTS(java.lang.String catalogName, java.lang.String schemaPattern, java.lang.String typeNamePattern, java.lang.String udtTypes, java.lang.String options, java.sql.ResultSet[] rs) throws java.sql.SQLException
Map SQLUDTS to EmbedDatabaseMetaData.getUDTs- Parameters:
catalogName
- SYSIBM.SQLUDTS CatalogName varchar(128),schemaPattern
- SYSIBM.SQLUDTS Schema_Name_Pattern varchar(128),typeNamePattern
- SYSIBM.SQLUDTS Type_Name_Pattern varchar(128),udtTypes
- SYSIBM.SQLUDTS UDTTypes varchar(128),options
- SYSIBM.SQLUDTS Options varchar(4000))rs
- output parameter, the resultset object containing the result of getUDTs, which will be empty- Throws:
java.sql.SQLException
-
METADATA
public static void METADATA(java.sql.ResultSet[] rs) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
isForODBC
private static boolean isForODBC(java.lang.String options)
Helper for ODBC metadata calls.- Parameters:
options
- String containig the options to search through.- Returns:
- True if options contain ODBC indicator; false otherwise.
-
SYSCS_SET_DATABASE_PROPERTY
public static void SYSCS_SET_DATABASE_PROPERTY(java.lang.String key, java.lang.String value) throws java.sql.SQLException
Set/delete the value of a property of the database in current connection.Will be called as SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY.
- Parameters:
key
- The property key.value
- The new value, if null the property is deleted.- Throws:
java.sql.SQLException
- if a database error occurs
-
setDatabaseProperty
private static void setDatabaseProperty(java.lang.String key, java.lang.String value, Securable authorizationCheck) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
SYSCS_GET_DATABASE_PROPERTY
public static java.lang.String SYSCS_GET_DATABASE_PROPERTY(java.lang.String key) throws java.sql.SQLException
Get the value of a property of the database in current connection.Will be called as SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY.
- Parameters:
key
- The property key.- Throws:
java.sql.SQLException
- if a database error occurs
-
getProperty
private static java.lang.String getProperty(java.lang.String key, Securable authorizationCheck) throws java.sql.SQLException
This method exists so that we can get a property value without performing authorization checks.- Throws:
java.sql.SQLException
-
SYSCS_UPDATE_STATISTICS
public static void SYSCS_UPDATE_STATISTICS(java.lang.String schemaname, java.lang.String tablename, java.lang.String indexname) throws java.sql.SQLException
Update the statistics for 1)all the indexes or 2)a specific index on a table.Calls either "alter table tablename all update statistics " sql or "alter table tablename update statistics indexname" sql This routine will be called when an application calls: SYSCS_UTIL.SYSCS_UPDATE_STATISTICS
- Parameters:
schemaname
- schema name of the table/index(es) whose statistics will be updated. null will mean use the current schema to resolve the table name. Empty string for schema name will raise an exception.tablename
- table name of the index(es) whose statistics will be updated. A null value or an empty string will throw table not found exception. Must be non-null.indexname
- If null, then update the statistics for all the indexes for the given table name. If not null and not empty string, then the user wants to update the statistics for only the give index name. Empty string for index name will raise an exception.- Throws:
java.sql.SQLException
-
SYSCS_DROP_STATISTICS
public static void SYSCS_DROP_STATISTICS(java.lang.String schemaname, java.lang.String tablename, java.lang.String indexname) throws java.sql.SQLException
Drop the statistics for 1)all the indexes or 2)a specific index on a table.- Parameters:
schemaname
- schema name of the table/index(es) whose statistics will be dropped. null will mean use the current schema to resolve the table name. Empty string for schema name will raise an exception.tablename
- table name of the index(es) whose statistics will be dropped. A null value or an empty string will throw table not found exception. Must be non-null.indexname
- If null, then drop the statistics for all the indexes for the given table name. If not null and not empty string, then the user wants to drop the statistics for only the give index name. Empty string for index name will raise an exception.- Throws:
java.sql.SQLException
-
basicSchemaTableValidation
private static java.lang.String basicSchemaTableValidation(java.lang.String schemaname, java.lang.String tablename) throws java.sql.SQLException
Do following checks a)Schema name can't be empty string b)If schema name is null, then we use current schema c)Table name can't be null or empty string- Parameters:
schemaname
- If schema name is null, then we will use the current schema to resolve the table name. Empty string for schema name will raise an exception.tablename
- If table name is null or an empty string, we will throw table not found exception.- Returns:
- schemaname.tablename or tablename
- Throws:
java.sql.SQLException
- a)if schema name is empty string b)if table name is empty string c)if table name is null
-
SYSCS_COMPRESS_TABLE
public static void SYSCS_COMPRESS_TABLE(java.lang.String schemaname, java.lang.String tablename, short sequential) throws java.sql.SQLException
Compress the table.Calls the "alter table compress {sequential}" sql. This syntax is not db2 compatible so it mapped by a system routine. This routine will be called when an application calls: SYSCS_UTIL.SYSCS_COMPRESS_TABLE
- Parameters:
schemaname
- schema name of the table to compress. null will mean use the current schema to resolve the table name. Empty string for schema name will raise an exception.tablename
- table name of the table to compress. A null value or an empty string will throw table not found exception. Must be non-null.sequential
- if non-zero then rebuild indexes sequentially, if 0 then rebuild all indexes in parallel.- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_FREEZE_DATABASE
public static void SYSCS_FREEZE_DATABASE() throws java.sql.SQLException
Freeze the database.Call internal routine to freeze the database so that a backup can be made.
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_UNFREEZE_DATABASE
public static void SYSCS_UNFREEZE_DATABASE() throws java.sql.SQLException
Unfreeze the database.Call internal routine to unfreeze the database, which was "freezed" by calling SYSCS_FREEZE_DATABASE(). can be made.
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_CHECKPOINT_DATABASE
public static void SYSCS_CHECKPOINT_DATABASE() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
SYSCS_BACKUP_DATABASE
public static void SYSCS_BACKUP_DATABASE(java.lang.String backupDir) throws java.sql.SQLException
Backup the database to a backup directory. This procedure will throw error, if there are any unlogged operation executed in the same transaction backup is started. If there any unlogged operations in progess in other transaction, it will wait until those transactions are completed before starting the backup. Examples of unlogged operations include: create index and bulk insert. Note that once the backup begins these operations will not block, instead they are automatically converted into logged operations.- Parameters:
backupDir
- the name of the directory where the backup should be stored. This directory will be created if it does not exist.- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_BACKUP_DATABASE_NOWAIT
public static void SYSCS_BACKUP_DATABASE_NOWAIT(java.lang.String backupDir) throws java.sql.SQLException
Backup the database to a backup directory. This procedure will throw error, if there are any uncommitted unlogged operation before stating the backup. It will not wait for the unlogged operations to complete. Examples of unlogged operations include: create index and bulk insert. Note that once the backup begins these operations will not block, instead they are automatically converted into logged operations.- Parameters:
backupDir
- the name of the directory where the backup should be stored. This directory will be created if it does not exist.- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE
public static void SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(java.lang.String backupDir, short deleteOnlineArchivedLogFiles) throws java.sql.SQLException
Backup the database to a backup directory and enable the log archive mode that will keep the archived log files required for roll-forward from this version of the backup. This procedure will throw error if there are any unlogged operation executed in the same transaction backup is started. If there any unlogged operations in progess in other transaction, it will wait until those transactions are completed before starting the backup. Examples of unlogged operations include: create index and bulk insert. Note that once the backup begins these operations will not block, instead they are automatically converted into logged operations.- Parameters:
backupDir
- the name of the directory where the backup should be stored. This directory will be created if not it does not exist.deleteOnlineArchivedLogFiles
- If non-zero deletes online archived log files that exist before this backup, delete will occur only after the backup is complete.- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT
public static void SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(java.lang.String backupDir, short deleteOnlineArchivedLogFiles) throws java.sql.SQLException
Backup the database to a backup directory and enable the log archive mode that will keep the archived log files required for roll-forward from this version backup. This procedure will throw error, if there are any uncommitted unlogged operation before stating the backup. It will not wait for the unlogged operations to complete. Examples of unlogged operations include: create index and bulk insert. Note that once the backup begins these operations will not block, instead they are automatically converted into logged operations.- Parameters:
backupDir
- the name of the directory where the backup should be stored. This directory will be created if not it does not exist.deleteOnlineArchivedLogFiles
- If non-zero deletes online archived log files that exist before this backup, delete will occur only after the backup is complete.- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_DISABLE_LOG_ARCHIVE_MODE
public static void SYSCS_DISABLE_LOG_ARCHIVE_MODE(short deleteOnlineArchivedLogFiles) throws java.sql.SQLException
Disables the log archival process, i.e No old log files will be kept around for a roll-forward recovery.- Parameters:
deleteOnlineArchivedLogFiles
- If non-zero deletes all the online archived log files that exist before this call immediately.- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_SET_RUNTIMESTATISTICS
public static void SYSCS_SET_RUNTIMESTATISTICS(short enable) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
SYSCS_SET_STATISTICS_TIMING
public static void SYSCS_SET_STATISTICS_TIMING(short enable) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
SYSCS_CHECK_TABLE
public static int SYSCS_CHECK_TABLE(java.lang.String schema, java.lang.String tablename) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
SYSCS_INPLACE_COMPRESS_TABLE
public static void SYSCS_INPLACE_COMPRESS_TABLE(java.lang.String schema, java.lang.String tablename, short purgeRows, short defragmentRows, short truncateEnd) throws java.sql.SQLException
Implementation of SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE().Code which implements the following system procedure: void SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE( IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN PURGE_ROWS SMALLINT, IN DEFRAGMENT_ROWS SMALLINT, IN TRUNCATE_END SMALLINT)
Use the SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE system procedure to reclaim unused, allocated space in a table and its indexes. Typically, unused allocated space exists when a large amount of data is deleted from a table, and there have not been subsequent inserts to use the space freed by the deletes. By default, Derby does not return unused space to the operating system. For example, once a page has been allocated to a table or index, it is not automatically returned to the operating system until the table or index is destroyed. SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE allows you to return unused space to the operating system.
This system procedure can be used to force 3 levels of in place compression of a SQL table: PURGE_ROWS, DEFRAGMENT_ROWS, TRUNCATE_END. Unlike SYSCS_UTIL.SYSCS_COMPRESS_TABLE() all work is done in place in the existing table/index.
Syntax: SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE( IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN PURGE_ROWS SMALLINT, IN DEFRAGMENT_ROWS SMALLINT, IN TRUNCATE_END SMALLINT)
SCHEMANAME: An input argument of type VARCHAR(128) that specifies the schema of the table. Passing a null will result in an error.
TABLENAME: An input argument of type VARCHAR(128) that specifies the table name of the table. The string must exactly match the case of the table name, and the argument of "Fred" will be passed to SQL as the delimited identifier 'Fred'. Passing a null will result in an error.
PURGE_ROWS: If PURGE_ROWS is set to non-zero then a single pass is made through the table which will purge committed deleted rows from the table. This space is then available for future inserted rows, but remains allocated to the table. As this option scans every page of the table, it's performance is linearly related to the size of the table.
DEFRAGMENT_ROWS: If DEFRAGMENT_ROWS is set to non-zero then a single defragment pass is made which will move existing rows from the end of the table towards the front of the table. The goal of the defragment run is to empty a set of pages at the end of the table which can then be returned to the OS by the TRUNCATE_END option. It is recommended to only run DEFRAGMENT_ROWS, if also specifying the TRUNCATE_END option. This option scans the whole table and needs to update index entries for every base table row move, and thus execution time is linearly related to the size of the table.
TRUNCATE_END: If TRUNCATE_END is set to non-zero then all contiguous pages at the end of the table will be returned to the OS. Running the PURGE_ROWS and/or DEFRAGMENT_ROWS passes options may increase the number of pages affected. This option itself does no scans of the table, so performs on the order of a few system calls.
SQL example: To compress a table called CUSTOMER in a schema called US, using all available compress options: call SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE('US', 'CUSTOMER', 1, 1, 1); To quickly just return the empty free space at the end of the same table, this option will run much quicker than running all phases but will likely return much less space: call SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE('US', 'CUSTOMER', 0, 0, 1); Java example: To compress a table called CUSTOMER in a schema called US, using all available compress options: CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_COMPRESS_TABLE(?, ?, ?, ?, ?)"); cs.setString(1, "US"); cs.setString(2, "CUSTOMER"); cs.setShort(3, (short) 1); cs.setShort(4, (short) 1); cs.setShort(5, (short) 1); cs.execute(); To quickly just return the empty free space at the end of the same table, this option will run much quicker than running all phases but will likely return much less space: CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_COMPRESS_TABLE(?, ?, ?, ?, ?)"); cs.setString(1, "US"); cs.setString(2, "CUSTOMER"); cs.setShort(3, (short) 0); cs.setShort(4, (short) 0); cs.setShort(5, (short) 1); cs.execute();
It is recommended that the SYSCS_UTIL.SYSCS_COMPRESS_TABLE procedure is issued in auto-commit mode. Note: This procedure acquires an exclusive table lock on the table being compressed. All statement plans dependent on the table or its indexes are invalidated. For information on identifying unused space, see the Derby Server and Administration Guide. TODO LIST: o defragment requires table level lock in nested user transaction, which will conflict with user lock on same table in user transaction.
- Throws:
java.sql.SQLException
-
SYSCS_GET_RUNTIMESTATISTICS
public static java.lang.String SYSCS_GET_RUNTIMESTATISTICS() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
INSTALL_JAR
public static void INSTALL_JAR(java.lang.String url, java.lang.String jar, int deploy) throws java.sql.SQLException
Install a jar file in the database. SQLJ.INSTALL_JAR- Parameters:
url
- URL of the jar file to be installed in the database.jar
- SQL name jar will be installed as.deploy
- Ignored.- Throws:
java.sql.SQLException
- Error installing jar file.
-
REPLACE_JAR
public static void REPLACE_JAR(java.lang.String url, java.lang.String jar) throws java.sql.SQLException
Replace a jar file in the database. SQLJ.REPLACE_JAR- Parameters:
url
- URL of the jar file to be installed in the database.jar
- SQL name of jar to be replaced.- Throws:
java.sql.SQLException
- Error replacing jar file.
-
REMOVE_JAR
public static void REMOVE_JAR(java.lang.String jar, int undeploy) throws java.sql.SQLException
Remove a jar file from the database.- Parameters:
jar
- SQL name of jar to be replaced.undeploy
- Ignored.- Throws:
java.sql.SQLException
- Error removing jar file.
-
checkJarSQLName
private static void checkJarSQLName(java.lang.String sqlName) throws StandardException
- Throws:
StandardException
-
SYSCS_EXPORT_TABLE
public static void SYSCS_EXPORT_TABLE(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset) throws java.sql.SQLException
Export data from a table to given file.Will be called by system procedure: SYSCS_EXPORT_TABLE(IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672) , IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1) , IN CODESET VARCHAR(128))
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_EXPORT_TABLE_LOBS_TO_EXTFILE
public static void SYSCS_EXPORT_TABLE_LOBS_TO_EXTFILE(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, java.lang.String lobsFileName) throws java.sql.SQLException
Export data from a table to given files. Large objects are exported to an external file and the reference to it is written in the main export file.Will be called by system procedure: SYSCS_EXPORT_TABLE_LOBS_TO_EXTFILE(IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672) , IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1) , IN CODESET VARCHAR(128), IN LOBSFILENAME VARCHAR(32672))
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_EXPORT_QUERY
public static void SYSCS_EXPORT_QUERY(java.lang.String selectStatement, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset) throws java.sql.SQLException
Export data from a select statement to given file.Will be called as SYSCS_EXPORT_QUERY(IN SELECTSTATEMENT VARCHAR(32672), IN FILENAME VARCHAR(32672) , IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1) , IN CODESET VARCHAR(128))
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
public static void SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE(java.lang.String selectStatement, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, java.lang.String lobsFileName) throws java.sql.SQLException
Export data from a select statement to given file. Large objects are exported to an external file and the reference to it is written in the main export file.Will be called as SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE(IN SELECTSTATEMENT VARCHAR(32672), IN FILENAME VARCHAR(32672) , IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1) , IN CODESET VARCHAR(128), IN LOBSFILENAME VARCHAR(32672))
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_IMPORT_TABLE
public static void SYSCS_IMPORT_TABLE(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace) throws java.sql.SQLException
Import data from a given file to a table.Will be called by system procedure as SYSCS_IMPORT_TABLE(IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672) , IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1) , IN CODESET VARCHAR(128), IN REPLACE SMALLINT)
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_IMPORT_TABLE_BULK
public static void SYSCS_IMPORT_TABLE_BULK(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace, short skip) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
rollBackAndThrowSQLException
private static void rollBackAndThrowSQLException(java.sql.Connection conn, java.sql.SQLException se) throws java.sql.SQLException
issue a rollback when SQLException se occurs. If SQLException ouccurs when rollback, the new SQLException will be added into the chain of se.- Throws:
java.sql.SQLException
-
SYSCS_IMPORT_TABLE_LOBS_FROM_EXTFILE
public static void SYSCS_IMPORT_TABLE_LOBS_FROM_EXTFILE(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace) throws java.sql.SQLException
Import data from a given file to a table. Data for large object columns is in an external file, the reference to it is in the main input file. Read the lob data from the external file using the lob location info in the main import file.Will be called by system procedure as SYSCS_IMPORT_TABLE_LOBS_FROM_EXTFILE(IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN FILENAME VARCHAR(32672) , IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1) , IN CODESET VARCHAR(128), IN REPLACE SMALLINT)
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_IMPORT_DATA
public static void SYSCS_IMPORT_DATA(java.lang.String schemaName, java.lang.String tableName, java.lang.String insertColumnList, java.lang.String columnIndexes, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace) throws java.sql.SQLException
Import data from a given file into the specified table columns from the specified columns in the file.Will be called as SYSCS_IMPORT_DATA (IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN INSERTCOLUMNLIST VARCHAR(32672), IN COLUMNINDEXES VARCHAR(32672), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128), IN REPLACE SMALLINT)
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_IMPORT_DATA_BULK
public static void SYSCS_IMPORT_DATA_BULK(java.lang.String schemaName, java.lang.String tableName, java.lang.String insertColumnList, java.lang.String columnIndexes, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace, short skip) throws java.sql.SQLException
Import data from a given file into the specified table columns skipping header lines from the specified columns in the file.Will be called as SYSCS_IMPORT_DATA_BULK (IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN INSERTCOLUMNLIST VARCHAR(32672), IN COLUMNINDEXES VARCHAR(32672), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128), IN REPLACE SMALLINT, IN SKIP SMALLINT)
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_IMPORT_DATA_LOBS_FROM_EXTFILE
public static void SYSCS_IMPORT_DATA_LOBS_FROM_EXTFILE(java.lang.String schemaName, java.lang.String tableName, java.lang.String insertColumnList, java.lang.String columnIndexes, java.lang.String fileName, java.lang.String columnDelimiter, java.lang.String characterDelimiter, java.lang.String codeset, short replace) throws java.sql.SQLException
Import data from a given file into the specified table columns from the specified columns in the file. Data for large object columns is in an external file, the reference to it is in the main input file. Read the lob data from the external file using the lob location info in the main import file.Will be called as SYSCS_IMPORT_DATA_LOBS_FROM_EXTFILE(IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN INSERTCOLUMNLIST VARCHAR(32672), IN COLUMNINDEXES VARCHAR(32672), IN FILENAME VARCHAR(32672), IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER CHAR(1), IN CODESET VARCHAR(128), IN REPLACE SMALLINT)
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_BULK_INSERT
public static void SYSCS_BULK_INSERT(java.lang.String schemaName, java.lang.String tableName, java.lang.String vtiName, java.lang.String vtiArg) throws java.sql.SQLException
Perform bulk insert using the specificed vti .Will be called as SYSCS_BULK_INSERT (IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN VTINAME VARCHAR(32672), IN VTIARG VARCHAR(32672))
- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_RELOAD_SECURITY_POLICY
public static void SYSCS_RELOAD_SECURITY_POLICY() throws java.sql.SQLException
Reload the policy file.System procedure called thusly: SYSCS_UTIL.SYSCS_RELOAD_SECURITY_POLICY()
- Throws:
java.sql.SQLException
-
PI
public static double PI()
Method to return the constant PI. SYSFUN.PI().- Returns:
- PI
-
COT
public static double COT(double value)
Cotangent function. SYSFUN.COT- Returns:
- 1 / tan(x)
- See Also:
- HyperbolicFunctions
-
SIGN
public static int SIGN(double value)
Method to return the sign of the given value. SYSFUN.SIGN().- Returns:
- 0, 1 or -1
-
RAND
public static double RAND(int seed)
Pseudo-random number function.- Returns:
- a random number
-
SYSCS_SET_USER_ACCESS
public static void SYSCS_SET_USER_ACCESS(java.lang.String userName, java.lang.String connectionPermission) throws java.sql.SQLException
Set the connection level authorization for a specific user - SYSCS_UTIL.SYSCS_SET_USER_ACCESS.- Parameters:
userName
- name of the user in its normal form (not a SQL identifier).connectionPermission
-- Throws:
java.sql.SQLException
- Error setting the permission
-
removeFromAccessList
private static void removeFromAccessList(java.lang.String listProperty, java.lang.String userName) throws java.sql.SQLException, StandardException
Utility method for SYSCS_SET_USER_ACCESS removes a user from one of the access lists, driven by the property name.- Throws:
java.sql.SQLException
StandardException
-
SYSCS_GET_USER_ACCESS
public static java.lang.String SYSCS_GET_USER_ACCESS(java.lang.String userName) throws java.sql.SQLException
Get the connection level authorization for a specific user - SYSCS_UTIL.SYSCS_GET_USER_ACCESS.- Parameters:
userName
- name of the user in its normal form (not a SQL identifier).- Throws:
java.sql.SQLException
-
SYSCS_INVALIDATE_STORED_STATEMENTS
public static void SYSCS_INVALIDATE_STORED_STATEMENTS() throws java.sql.SQLException
Invalidate all the stored statements so they will get recompiled when executed next time around.- Throws:
java.sql.SQLException
-
SYSCS_EMPTY_STATEMENT_CACHE
public static void SYSCS_EMPTY_STATEMENT_CACHE() throws java.sql.SQLException
Empty as much of the cache as possible. It is not guaranteed that the cache is empty after this call, as statements may be kept by currently executing queries, activations that are about to be garbage collected.- Throws:
java.sql.SQLException
-
SYSCS_SET_XPLAIN_MODE
public static void SYSCS_SET_XPLAIN_MODE(int mode) throws java.sql.SQLException, StandardException
this procedure switches between the different xplain modes- Parameters:
mode
- either 0 for explain only, or 1 for explain and execute (default)- Throws:
java.sql.SQLException
StandardException
-
SYSCS_GET_XPLAIN_MODE
public static int SYSCS_GET_XPLAIN_MODE() throws java.sql.SQLException, StandardException
This procedure returns the current status of the xplain mode. If the XPLAIN mode is non-zero, meaning that it is ON, then statements are being XPLAIN'd only, not executed.- Returns:
- 0 if XPLAIN mode is off, non-zero if on.
- Throws:
java.sql.SQLException
StandardException
-
SYSCS_SET_XPLAIN_SCHEMA
public static void SYSCS_SET_XPLAIN_SCHEMA(java.lang.String schemaName) throws java.sql.SQLException, StandardException
This procedure sets the current xplain schema. If the schema is not set, runtime statistics are captured as a textual stream printout. If it is set, statisitcs information is stored in that schema in user tables.- Parameters:
schemaName
- May be an empty string.- Throws:
java.sql.SQLException
StandardException
-
hasSchema
private static boolean hasSchema(java.sql.Connection conn, java.lang.String schemaName) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
hasTable
private static boolean hasTable(java.sql.Connection conn, java.lang.String schemaName, java.lang.String tableName) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
createXplainSchema
private static void createXplainSchema(java.lang.String schemaName) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
createXplainTable
private static void createXplainTable(LanguageConnectionContext lcc, java.lang.String schemaName, XPLAINTableDescriptor t) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
SYSCS_GET_XPLAIN_SCHEMA
public static java.lang.String SYSCS_GET_XPLAIN_SCHEMA() throws java.sql.SQLException, StandardException
This procedure returns the current set XPLAIN_SCHEMA- Returns:
- schema name, may be blank if no schema currently set.
- Throws:
java.sql.SQLException
StandardException
-
SYSCS_CREATE_USER
public static void SYSCS_CREATE_USER(java.lang.String userName, java.lang.String password) throws java.sql.SQLException
Create a new user.- Throws:
java.sql.SQLException
-
addUser
public static void addUser(java.lang.String userName, java.lang.String password, TransactionController tc) throws java.sql.SQLException
Create a new user (this entry is called when bootstrapping the credentials of the DBO at database creation time.- Throws:
java.sql.SQLException
-
makeUserDescriptor
private static UserDescriptor makeUserDescriptor(DataDictionary dd, TransactionController tc, java.lang.String userName, java.lang.String password) throws StandardException
- Throws:
StandardException
-
SYSCS_RESET_PASSWORD
public static void SYSCS_RESET_PASSWORD(java.lang.String userName, java.lang.String password) throws java.sql.SQLException
Reset a user's password.- Throws:
java.sql.SQLException
-
resetAuthorizationIDPassword
private static void resetAuthorizationIDPassword(java.lang.String userName, java.lang.String password) throws java.sql.SQLException
Reset the password for an already normalized authorization id.- Throws:
java.sql.SQLException
-
SYSCS_MODIFY_PASSWORD
public static void SYSCS_MODIFY_PASSWORD(java.lang.String password) throws java.sql.SQLException
Change a user's password.- Throws:
java.sql.SQLException
-
SYSCS_DROP_USER
public static void SYSCS_DROP_USER(java.lang.String userName) throws java.sql.SQLException
Drop a user.- Throws:
java.sql.SQLException
-
checkLegalUser
private static void checkLegalUser(DataDictionary dd, java.lang.String userName) throws StandardException
Raise an exception if the user doesn't exist. See commentary on DERBY-5648.- Throws:
StandardException
-
normalizeUserName
private static java.lang.String normalizeUserName(java.lang.String userName) throws java.sql.SQLException
Normalize the user name so that there is only one set of credentials for a given authorization id.- Throws:
java.sql.SQLException
-
SYSCS_GET_DATABASE_NAME
public static java.lang.String SYSCS_GET_DATABASE_NAME() throws java.sql.SQLException
Return the database name- Returns:
- database name
- Throws:
java.sql.SQLException
-
SYSCS_PEEK_AT_SEQUENCE
public static java.lang.Long SYSCS_PEEK_AT_SEQUENCE(java.lang.String schemaName, java.lang.String sequenceName) throws java.sql.SQLException
Peek at the current value of a sequence generator without advancing it.- Parameters:
schemaName
- The name of the schema holding the sequence.sequenceName
- The name of the sequence in that schema.- Throws:
java.sql.SQLException
- if a database error occurs
-
SYSCS_PEEK_AT_IDENTITY
public static java.lang.Long SYSCS_PEEK_AT_IDENTITY(java.lang.String schemaName, java.lang.String tableName) throws java.sql.SQLException
Peek at the current value of an identity generator without advancing it.- Parameters:
schemaName
- The name of the schema holding the table.tableName
- The name of the table in that schema.- Throws:
java.sql.SQLException
- if a database error occurs
-
getMonitor
private static ModuleFactory getMonitor()
Helper routine which looks up the monitor.
-
-