public class SQLCommands extends Object
| Constructor and Description | 
|---|
SQLCommands()
Creates a new SQLCommands instance without creating
 a Connection to the database. 
 | 
SQLCommands(Connection con)
Creates a new SQLCommands instance,
 given an existing Connection to a database. 
 | 
SQLCommands(Connection con,
           boolean isPostgres)
Creates a new SQLCommands instance,
 given an existing Connection to a database. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
changeUserPassword(String name,
                  String password)
Changes a database user's password. 
 | 
void | 
createTablespace(String name,
                int size,
                String init,
                String next,
                String file,
                boolean reuse)
Creates a tablespace in the database, writing the tablespace
 file in the directory specified by  
file. | 
void | 
createTablespace(String name,
                String size,
                String next)
Creates a tablespace in the database without the dbf file name
 This will work only if the DB_CREATE_FILE_DEST parameter is
 initialized. 
 | 
String | 
createTempUser(String prefix)
Creates a temporary database user (schema) named T
 with password (identified by) T (same as the name),
  
where T = prefixi
 where i = {0..n} and n = Integer.MAX_VALUE - 1
 
 Note: this algorithm will fail if there are already n
 database users named: prefixi. | 
void | 
createUser(String name,
          String pass)
Creates a user in the database without specifying a default tablespace. 
 | 
void | 
createUser(String name,
          String pass,
          String tbs,
          String tempTbs)
Creates a user in the database. 
 | 
void | 
dropTablespace(String name,
              boolean includeContents,
              boolean cascade)
Drops a tablespace from the database, optionally using the
 "including contents" and "cascade constraints" SQL directives. 
 | 
void | 
dropUser(String name,
        boolean cascade)
Drops a user from the database, optionally deleting every object
 the user owns. 
 | 
String | 
getCharacterSet()
Returns the value of the NLS_CHARACTERSET parameter from
 the NLS_DATABASE_PARAMETERS table. 
 | 
String | 
getCurrentInstance()
Returns the current instance (service name, or ORACLE_SID)
 of this Oracle databasse connection. 
 | 
String | 
getDefaultTablespaceDirectory()
Returns the directory where the default tablespaces are stored,
 or null if no default tablespaces are found. 
 | 
String | 
getLanguage()
Returns the value of the NLS_LANGUAGE parameter
 from the NLS_DATABASE_PARAMETERS table. 
 | 
int | 
getOnlineNonSystemRollbackSegs()
Returns the number of online non-system rollback segments. 
 | 
int | 
getParameterValueAsInt(String param)
Returns the value of a parameter from the  
v$parameter table. | 
String | 
getParameterValueAsString(String param)
Returns the value of a parameter from the  
v$parameter table. | 
Enumeration | 
getRows(String column,
       String table,
       boolean ascending)
Returns an Enumeration containing the row values as Strings in
 the specified column of the specified table, optionally in
 in ascending order. 
 | 
Enumeration | 
getRowsWhereColumnEquals(String column,
                        String table,
                        String keyColumn,
                        String keyValue)
Returns the row values of a given column in a given table where
 a certain column in that row has a certain value. 
 | 
Enumeration | 
getRowsWhereColumnMatches(String column,
                         String table,
                         String keyColumn,
                         String keyValue)
Returns the row values of a given column in a given table where
 a certain column in that row matches a certain value. 
 | 
Statement | 
getStatement()
Returns the Statement used internally by this SQLCommands instance. 
 | 
String | 
getTablespaceFile(String tablespace)
Returns the full filename (including absolute path) of the tablespace
 file for a given tablespace, or null if the tablespace does not exist. 
 | 
Enumeration | 
getTablespaceNames()
Returns an Enumeration containing the names of every tablespace in the
 database, in ascending order. 
 | 
Enumeration | 
getUserNames()
Returns an Enumeration containing the names of every user in the
 database, in ascending order. 
 | 
Enumeration | 
getUserNames(String userName)
Returns an Enumeration containing the names of every user in the
 database filtered based on the username. 
 | 
String | 
getValueWhereKeyEquals(String table,
                      String column,
                      String key,
                      String keyVal)
Executes a SQL query of the following form:
  
 SELECT column FROM table WHERE key = keyVal;
  | 
void | 
grantConnectResource(String name)
Grants connect and resource priviledges to a user in the database. 
 | 
void | 
grantConnectResource(String name,
                    String superUserName)
Grants connect and resource priviledges to a user in the database. 
 | 
void | 
grantPriviledgeToUser(String name,
                     String priviledge)
Grants a priviledge to a user in the database. 
 | 
boolean | 
isContextInstalled()
Returns true if context seems to be installed in the database. 
 | 
boolean | 
isFullTextIndexingEnabled()
Gets whether full-text indexing is enabled. 
 | 
boolean | 
isIfsSchemaContextEnabled(String schema)
Deprecated. 
 
use S_Media.getContextEnabledState 
 | 
boolean | 
isPartitioningInstalled()
Returns true if the partitioning option seems to be installed
 in the database. 
 | 
boolean | 
isRoleGrantedToUser(String username,
                   String role)
Determines if a user  
username has been granted the role
 role. | 
void | 
setConnection(Connection con)
Sets the Connection to the database. 
 | 
void | 
setContextPreference(String preference,
                    String attribute,
                    String value)
Sets a context preference attribute to a String value. 
 | 
boolean | 
tablespaceExists(String tablespace)
Returns true if the given tablespace exists in the database. 
 | 
void | 
unlockAlterUserPassword(String name,
                       String password)
Changes a database user's password and unlocks the user 
 | 
boolean | 
userExists(String name)
Returns true if the given user exists in the database. 
 | 
public SQLCommands()
public SQLCommands(Connection con) throws SQLException
con - an existing Connection to a database.SQLException - if an error occurs when using the new Connectionpublic SQLCommands(Connection con, boolean isPostgres) throws SQLException
con - an existing Connection to a database.isPostgres - indicates whether the database type is Postgres.SQLException - if an error occurs when using the new Connectionpublic void setConnection(Connection con) throws SQLException
con - the Connection to use.SQLException - if an error occurs when trying to
                           create a Statement from the new Connection.public Statement getStatement()
public void createTablespace(String name, int size, String init, String next, String file, boolean reuse) throws SQLException
file.
 Note: tablespaces are always created with UPPERCASE names; however, the tablespace filename is user-defined in this method.
Note: if the tablespace file already exists, it is reused and the file's previous contents are lost.
name - the name of the tablespace.size - the size (in megabytes) of the tablespace.init - the initial extent sizenext - the next extent sizefile - the filename (including absolute path) of the
               tablespace file.SQLException - if an error occurs.public void createTablespace(String name, String size, String next) throws SQLException
Note: tablespaces are always created with UPPERCASE names; however, the tablespace filename is generated by the database
name - the name of the tablespace.size - the size of the tablespace.next - the next extent sizeSQLException - if an error occurs.public void dropUser(String name, boolean cascade) throws SQLException
name - the user to drop (case-insensitive).cascade - true if this method should delete every object
                  owned by the user.SQLException - if an error occurs.public void changeUserPassword(String name, String password) throws SQLException
name - the user whose password to change (case-insensitive).password - the user's new password.SQLException - if an error occurs.public void unlockAlterUserPassword(String name, String password) throws SQLException
name - the user whose password to change (case-insensitive).password - the user's new password.SQLException - if an error occurs.public void dropTablespace(String name, boolean includeContents, boolean cascade) throws SQLException
name - the tablespace to drop (case insensitive).includeContents - true if "include contents" should be used.cascade - true if "cascade constraints" should be used.SQLException - if an error occurs.public void createUser(String name, String pass) throws SQLException
name - the user to create (case insensitive).pass - the password to assign to the user.SQLException - if an error occurs.public String getCurrentInstance() throws SQLException
SQLException - if an error occurs.public void createUser(String name, String pass, String tbs, String tempTbs) throws SQLException
name - the user to create (case-insensitive).pass - the password to assign to the user.tbs - the default tablespace to assign to the user.tempTbs - the temporary tablespace to assign to the user.SQLException - if an error occurs.public String createTempUser(String prefix) throws SQLException
prefixi
 Integer.MAX_VALUE - 1
 
 Note: this algorithm will fail if there are already n
 database users named: prefixi.
prefix - the prefix to use when naming the temporary user.SQLException - if a database error occurs, or if this
                           algorithm fails as described above.@Deprecated public boolean isIfsSchemaContextEnabled(String schema) throws SQLException
  SELECT MAX(indexed) FROM odm_media;
 
 SQLException - if an error occurs.public void grantConnectResource(String name) throws SQLException
name - the user to grant the priviledges to (case-insensitive).SQLException - if an error occurs.public void grantConnectResource(String name, String superUserName) throws SQLException
name - the user to grant the priviledges to (case-insensitive).superUserName - the superuser performing this operation.SQLException - if an error occurs.public void grantPriviledgeToUser(String name, String priviledge) throws SQLException
name - the user to grant the priviledge to (case insensitive).priviledge - the priviledge to grant.SQLException - if an error occurs.public int getParameterValueAsInt(String param) throws SQLException
v$parameter table.
 This table includes all paramters from the "init.ora" file.param - the name of the parameter to get the value of.v$paramter table,
          converted to an int.SQLException - if a database error occurs,
                           or if the given parameter does not exist in the
                           v$parameter table, or if the value
                           cannot be converted to an int.public String getParameterValueAsString(String param) throws SQLException
v$parameter table.
 This table includes all paramters from the "init.ora" file.param - the name of the parameter to get the value of.v$paramter table
          as a String.SQLException - if a database error occurs,
                           or if the given parameter does not exist in the
                           v$parameter table.public String getTablespaceFile(String tablespace) throws SQLException
Note: tablespace names are case sensitive.
tablespace - the name of the tablespace to get the file for.SQLException - if a database error occurs.public String getDefaultTablespaceDirectory() throws SQLException
 Note: the returned path includes the final file_separator character:
       i.e. "C:\ORACLE\ORADATA\ONI\"    on Windows NT,
       
 "/data/oracle/oradata/oni/" on Solaris.
SQLException - if a database error occurs.public String getCharacterSet() throws SQLException
SQLException - if a database error occurs.public String getLanguage() throws SQLException
SQLException - if a database error occurs.public void setContextPreference(String preference, String attribute, String value) throws SQLException
preference - the context preference to modify.attribute - the specific attribute to set.value - the value to set the parameter to.SQLException - if a database error occurs.public boolean isContextInstalled()
                           throws SQLException
dba_views.
 If the view exists, then context is assumed to be installed.SQLException - if a database error occurs.public boolean isFullTextIndexingEnabled()
                                  throws SQLException
SQLException - if the operation failspublic boolean isPartitioningInstalled()
                                throws SQLException
 The way this method checks for partitioning is pretty simple:
 it just queries the parameter 'partitioning' in v$option.
 If the value is 'true', then partitioning is assumed to be installed.
SQLException - if a database error occurs.public boolean tablespaceExists(String tablespace) throws SQLException
dba_tablespaces table.
 
 Note: the tablespace parameter is converted to uppercase.
tablespace - the tablespace to check the existence of.SQLException - if a database error occurs.public int getOnlineNonSystemRollbackSegs()
                                   throws SQLException
SQLException - if a database error occurs.public boolean isRoleGrantedToUser(String username, String role) throws SQLException
username has been granted the role
 role.
 Note: the given username and role name are always converted to UPPERCASE.
SQLException - if a database error occurs.public Enumeration getTablespaceNames() throws SQLException
SQLException - if a database error occurs.public Enumeration getUserNames() throws SQLException
SQLException - if a database error occurs.public Enumeration getUserNames(String userName) throws SQLException
userName - user name string used to filter the list of 
                   usersSQLException - if a database error occurs.public Enumeration getRows(String column, String table, boolean ascending) throws SQLException
SQLException - if a database error occurs.public Enumeration getRowsWhereColumnEquals(String column, String table, String keyColumn, String keyValue) throws SQLException
 SELECT column FROM table WHERE keyColumn = keyValue
 SQLException - if a database error occurs.public Enumeration getRowsWhereColumnMatches(String column, String table, String keyColumn, String keyValue) throws SQLException
 SELECT column FROM table WHERE keyColumn 
   like %keyValue%
 SQLException - if a database error occurs.public String getValueWhereKeyEquals(String table, String column, String key, String keyVal) throws SQLException
 SELECT column FROM table WHERE key = keyVal;
 table - the table to select from.column - the column to select.key - the column to use as the key for the where clause.keyVal - the String value to use in the where clause.SQLException - if a database error occurs.public boolean userExists(String name) throws SQLException
name parameter is converted to uppercase.name - the name of the user to check for.SQLException - if a database error occurs.Copyright © 2025. All rights reserved.