/************************************************************************
* *
* java.sql *
* *
* Interfaces: *
* CallableStatement PreparedStatement *
* Connection ResultSet *
* DatabaseMetaData ResultSetMetaData *
* Driver Statement *
* *
* Classes: *
* Date Time *
* DriverManager Timestamp *
* DriverPropertyInfo Types *
* *
* Exceptions: *
* DataTruncation SQLWarning *
* SQLException *
* *
************************************************************************/
package Test.Chris;
import java.sql.*;
public class Java_sql {
private boolean DBSERVER = false;
private String DBNAME = "jdbc:odbc:Regenit";
private String DBUSER = "";
private String DBPSWD = "";
public static void main(String[] args) {
Java_sql obj = new Java_sql();
obj.exercise();
System.exit(0);
}
public void exercise() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // load JDBC:ODBC bridge
} catch(ClassNotFoundException e) {
System.out.println(e);
}
drivermanager();
driver();
driverpropertyinfo();
connection();
databasemetadata();
statement();
callablestatement();
preparedstatement();
resultset();
resultsetmetadata();
date();
time();
timestamp();
}
/*********************************************************************
* *
* DriverManager: *
* *
* Desc: Provides a basic service for managing JDBC drivers *
* *
* Methods: *
* deregisterDriver getLoginTimeout setLoginTimeout *
* getConnection getLogStream setLogStream *
* getDriver println *
* getDrivers registerDriver *
* *
*********************************************************************/
void drivermanager() {
int i;
Driver Dv;
Connection Db;
java.io.PrintStream ios;
try {
i = DriverManager.getLoginTimeout(); // get max time in seconds for log in attempt
DriverManager.setLoginTimeout(5 * 60); // set max time in seconds for log in attempt
Dv = DriverManager.getDriver(DBNAME); // locate compatible driver
java.util.Enumeration z = DriverManager.getDrivers(); // get loaded JDBC drivers
while (z.hasMoreElements()) {
Dv = (Driver)z.nextElement();
}
Db = DriverManager.getConnection(DBNAME, DBUSER, DBPSWD); // connect to Db
/* Java screw up - PrintStream is deprecated!!!
try { // Set/Get the logging/tracing PrintStream
DriverManager.setLogStream(
new java.io.PrintStream(new java.io.FileOutputStream("DriverManager.txt")));
ios = DriverManager.getLogStream();
} catch(java.io.IOException e) {
}
DriverManager.println("hello"); // print a message to the current JDBC log stream
*/
//DriverManager.deregisterDriver(Dv); // drop a Driver from the DriverManager's list
DriverManager.registerDriver(Dv); // make driver known to the DriverManager
} catch(SQLException e) {
System.out.println(e);
}
}
/*********************************************************************
* *
* Driver Interface: *
* *
* Desc: interface that every driver class must implement *
* *
* Methods: *
* acceptsURL getMajorVersion getPropertyInfo *
* connect getMinorVersion jdbcCompliant *
* *
*********************************************************************/
void driver() {
int i;
boolean b;
java.util.Properties p = new java.util.Properties();;
Connection Db;
Driver Dv;
DriverPropertyInfo[] Dp;
String DBURL = "jdbc:odbc:Regenit";
try {
Dv = DriverManager.getDriver(DBNAME); // locate compatible driver
b = Dv.acceptsURL(DBURL); // test if can open a connection to the given URL
b = Dv.jdbcCompliant(); // test Driver is a genuine JDBC compliant driver
i = Dv.getMajorVersion(); // driver's major version number
i = Dv.getMinorVersion(); // driver's minor version number
// Dp = Dv.getPropertyInfo(DBURL, p); // discover what properties should prompt for
p.put("user", DBUSER);
p.put("password", DBPSWD);
Db = Dv.connect(DBURL, p); // Try to make a database connection to the given URL.
} catch(SQLException e) {
System.out.println(e);
}
}
/*********************************************************************
* *
* DriverPropertyInfo: *
* *
* Desc: x *
* *
* Vars: *
* choices name value *
* description required *
* *
*********************************************************************/
void driverpropertyinfo() {
/*
choices // If the value may be selected from a particular set of values, then this is an array of the possible values.
description // A brief description of the property.
name // The name of the property.
required // "required" is true if a value must be supplied for this property during Driver.connect.
value // "value" specifies the current value of the property, based on a combination of the information supplied to getPropertyInfo, the Java environment, and driver supplied default values.
*/
}
/*********************************************************************
* *
* Connection Interface: *
* *
* Desc: Represents a session with a specific database *
* *
* Vars: *
* TRANSACTION_NONE TRANSACTION_REPEATABLE_READ *
* TRANSACTION_READ_COMMITTED TRANSACTION_SERIALIZABLE *
* TRANSACTION_READ_UNCOMMITTED *
* *
* Methods: *
* clearWarnings getWarnings prepareStatement *
* close isClosed rollback *
* commit isReadOnly setAutoCommit *
* createStatement nativeSQL setCatalog *
* getAutoCommit prepareCall setReadOnly *
* getCatalog getTransactionIsolation *
* getMetaData setTransactionIsolation *
* *
*********************************************************************/
void connection() {
int i;
boolean b;
String s;
Connection Db;
Statement Ds;
PreparedStatement Dq;
CallableStatement Dp;
DatabaseMetaData Dm;
SQLWarning Dw;
try {
Db = DriverManager.getConnection(DBNAME, DBUSER, DBPSWD);
b = Db.isClosed(); // tests to see if a Connection is closed.
b = Db.isReadOnly(); // tests to see if the connection is in read-only mode.
Db.setReadOnly(false); // set read-only mode
Dm = Db.getMetaData(); // Connection information
i = Db.getTransactionIsolation(); // get/set current transaction isolation mode
switch(i) {
case Connection.TRANSACTION_NONE:
break;
case Connection.TRANSACTION_READ_COMMITTED:
break;
case Connection.TRANSACTION_READ_UNCOMMITTED:
break;
case Connection.TRANSACTION_REPEATABLE_READ:
break;
case Connection.TRANSACTION_SERIALIZABLE:
break;
}
Db.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
Db.commit(); // commit transanction
Db.rollback(); // rollback transaction
b = Db.getAutoCommit(); // get the current auto-commit state.
Db.setAutoCommit(false); // auto-commit mode = all SQL statements committed
Dw = Db.getWarnings(); // first warning reported by calls on Connection
Db.clearWarnings(); // clear warnings
s = Db.getCatalog(); // Connection's current catalog name.
Db.setCatalog("Regenit"); // Connection's database selection
Ds = Db.createStatement(); // used for SQL commands
Dq = Db.prepareStatement("SELECT * FROM options");
s = Db.nativeSQL("SELECT * FROM options"); // JDBC sql to native SQL translation
if (DBSERVER) {
Dp = Db.prepareCall("EXEC spIACodesState"); // used for stored procedures
}
Db.close(); // immediate release connection and JDBC resources
} catch(SQLException e) {
System.out.println(e);
}
}
/*********************************************************************
* *
* Statement Interface: *
* *
* Desc: Execute static SQL statement and obtain results *
* *
* Methods: *
* cancel getMaxFieldSize getWarnings *
* clearWarnings getMaxRows setCursorName *
* close getMoreResults setEscapeProcessing *
* execute getQueryTimeout setMaxFieldSize *
* executeQuery getResultSet setMaxRows *
* executeUpdate getUpdateCount setQueryTimeout *
* *
*********************************************************************/
void statement() {
int i;
boolean b;
Connection Db;
Statement Ds;
SQLWarning Dw;
ResultSet Rs;
ResultSet Xs;
try {
// database setup
Db = DriverManager.getConnection(DBNAME, DBUSER, DBPSWD);
Ds = Db.createStatement();
i = Ds.getMaxRows(); // get max rows that a ResultSet can contain
Ds.setMaxRows(0); // set max rows that a ResultSet can contain
Ds.setEscapeProcessing(true); // driver will escape substitute before sending the SQL
if (DBSERVER) {
i = Ds.getMaxFieldSize(); // get max amount of data returned for any column value
Ds.setMaxFieldSize(0); // set max amount of data returned for any column value
i = Ds.getQueryTimeout(); // get limit in seconds the driver waits for execute
Ds.setQueryTimeout(0); // set limit in seconds the driver waits for execute
}
// returns single ResultSet
Rs = Ds.executeQuery("SELECT * FROM options");
// execute SQL statement - true if ResultSet
if (DBSERVER) {
if (Ds.execute("EXEC spIACodesState")) {
Rs = Ds.getResultSet(); // returns the current result as a ResultSet
}
}
// execute a SQL INSERT, UPDATE or DELETE statement
i = Ds.executeUpdate("DELETE FROM options WHERE OptionName = 'TestKey'");
i = Ds.executeUpdate("INSERT INTO options VALUES('TestKey', 'Just Trying')");
i = Ds.executeUpdate("UPDATE options SET OptionValue = 'Hello' WHERE OptionName = 'TestKey'");
i = Ds.getUpdateCount(); // current result as an update count
Dw = Ds.getWarnings(); // first warning from Statement
Ds.clearWarnings(); // clear warnings
Ds.cancel(); // cancel a statement that is being executed by another thread
Ds.close(); // immediate release statement and JDBC resources
Db.close();
} catch(SQLException e) {
System.out.println(e);
}
/*
Ds.getMoreResults() // moves to a Statement's next result
Ds.setCursorName(String) // SQL cursor name used by subsequent Statement execute methods
*/
}
/*********************************************************************
* *
* ResultSet Interface: *
* *
* Desc: Provides access to a table of data *
* *
* Methods: *
* clearWarnings getCursorName getString *
* close getDate getTime *
* findColumn getDouble getTimestamp *
* getAsciiStream getFloat getUnicodeStream *
* getBigDecimal getInt getWarnings *
* getBinaryStream getLong next *
* getBoolean getMetaData wasNull *
* getByte getObject *
* getBytes getShort *
* *
*********************************************************************/
void resultset() {
int i;
boolean b;
String s;
Connection Db;
Statement Ds;
ResultSet Rs;
ResultSetMetaData Rm;
SQLWarning Rw;
try {
// database setup
Db = DriverManager.getConnection(DBNAME, DBUSER, DBPSWD);
Ds = Db.createStatement();
Rs = Ds.executeQuery("SELECT * FROM options");
b = Rs.next(); // first call to next makes first row the current row
s = Rs.getString("OptionName"); // Get column value in current row as java string.
i = Rs.findColumn("OptionValue"); // Map a column name to column index.
s = Rs.getString(i);
Rm = Rs.getMetaData(); // number, types and properties of ResultSet's columns
Rw = Rs.getWarnings(); // first warning from ResultSet
Rs.clearWarnings(); // clear warnings
Rs.close(); // immediate release resultset and JDBC resources
} catch(SQLException e) {
System.out.println(e);
}
/*
wasNull() // A column may have the value of SQL NULL; wasNull reports whether the last column read had this special value.
getAsciiStream(int) // A column value can be retrieved as a stream of ASCII characters and then read in chunks from the stream.
getAsciiStream(String) // A column value can be retrieved as a stream of ASCII characters and then read in chunks from the stream.
getBinaryStream(int) // A column value can be retrieved as a stream of uninterpreted bytes and then read in chunks from the stream.
getBinaryStream(String) // A column value can be retrieved as a stream of uninterpreted bytes and then read in chunks from the stream.
getCursorName() // Get the name of the SQL cursor used by this ResultSet.
getUnicodeStream(int) // A column value can be retrieved as a stream of Unicode characters and then read in chunks from the stream.
getUnicodeStream(String) // A column value can be retrieved as a stream of Unicode characters and then read in chunks from the stream.
*/
}
/*********************************************************************
* *
* ResultSetMetaData Interface: *
* *
* Desc: x *
* *
* Vars: *
* columnNoNulls columnNullable columnNullableUnknown *
* *
* Methods: *
* getCatalogName getPrecision isDefinitelyWritable *
* getColumnCount getScale isNullable *
* getColumnDisplaySize getSchemaName isReadOnly *
* getColumnLabel getTableName isSearchable *
* getColumnName isAutoIncrement isSigned *
* getColumnType isCaseSensitive isWritable *
* getColumnTypeName isCurrency *
* *
*********************************************************************/
void resultsetmetadata() {
int i;
int j;
boolean b;
String s;
Connection Db;
Statement Ds;
ResultSet Rs;
ResultSetMetaData Rm;
try {
// database setup
Db = DriverManager.getConnection(DBNAME, DBUSER, DBPSWD);
Ds = Db.createStatement();
Rs = Ds.executeQuery("SELECT * FROM options");
b = Rs.next();
Rm = Rs.getMetaData();
for (i = 1; i <= Rm.getColumnCount(); i++) { // number of columns in the ResultSet
s = Rm.getTableName(i); // column table name ("")
s = Rm.getCatalogName(i); // column table catalog name
s = Rm.getSchemaName(i); // column table schema ("")
s = Rm.getColumnName(i); // column name
s = Rm.getColumnLabel(i); // suggested column title
j = Rm.getColumnType(i); // column SQL type
s = Rm.getColumnTypeName(i); // column data source type name
j = Rm.getColumnDisplaySize(i); // column normal max width in chars
j = Rm.getPrecision(i); // column number of decimal digits?
j = Rm.getScale(i); // column number of digits right of decimal point
b = Rm.isAutoIncrement(i); // is column automatically numbered
b = Rm.isCaseSensitive(i); // does column's case matter
b = Rm.isCurrency(i); // is column a cash value
b = Rm.isDefinitelyWritable(i); // will a write on the column definitely succeed
j = Rm.isNullable(i); // can you put a NULL in this column
switch(j) {
case Rm.columnNoNulls: // does not allow NULL values
break;
case Rm.columnNullable: // allows NULL values
break;
case Rm.columnNullableUnknown:// nullability unknown
break;
}
b = Rm.isReadOnly(i); // is column definitely not writable
b = Rm.isSearchable(i); // can column be used in a where clause
b = Rm.isSigned(i); // is column a signed number
b = Rm.isWritable(i); // is possible for write on the column to succeed
}
Rs.close();
Ds.close();
} catch(SQLException e) {
System.out.println(e);
}
}
/*********************************************************************
* *
* Types: *
* *
* Desc: x *
* *
* Vars: *
* BIGINT FLOAT REAL *
* BINARY INTEGER SMALLINT *
* BIT LONGVARBINARY TIME *
* CHAR LONGVARCHAR TIMESTAMP *
* DATE NULL TINYINT *
* DECIMAL NUMERIC VARBINARY *
* DOUBLE OTHER VARCHAR *
* *
*********************************************************************/
void resultDump(ResultSet Rs) {
try {
ResultSetMetaData Rm = Rs.getMetaData();
for (int i = 1; i <= Rm.getColumnCount(); i++) {
if (i == 1) {
System.out.print("\"");
} else {
System.out.print(", \"");
}
System.out.print(Rm.getColumnName(i));
System.out.print("\"");
}
System.out.println("");
while (Rs.next()) {
for (int i = 1; i <= Rm.getColumnCount(); i++) {
if (i == 1) {
System.out.print("\"");
} else {
System.out.print(", \"");
}
switch (Rm.getColumnType(i)) {
case Types.BIGINT:
System.out.print(Rs.getLong(i));
break;
case Types.BINARY:
System.out.print(Rs.getBytes(i));
break;
case Types.BIT:
System.out.print(Rs.getBoolean(i));
break;
case Types.CHAR:
System.out.print(Rs.getString(i));
break;
case Types.DATE:
System.out.print(Rs.getDate(i));
break;
case Types.DECIMAL:
// System.out.print(Rs.getBigDecimal(i, Rm.getScale(i)));
break;
case Types.DOUBLE:
System.out.print(Rs.getDouble(i));
break;
case Types.FLOAT:
System.out.print(Rs.getDouble(i));
break;
case Types.INTEGER:
System.out.print(Rs.getInt(i));
break;
case Types.LONGVARBINARY:
System.out.print(Rs.getBytes(i));
break;
case Types.LONGVARCHAR:
System.out.print(Rs.getString(i));
break;
case Types.NULL:
System.out.print("null");
break;
case Types.NUMERIC:
// System.out.print(Rs.getBigDecimal(i, Rm.getScale(i)));
break;
case Types.OTHER:
System.out.print(Rs.getObject(i));
break;
case Types.REAL:
System.out.print(Rs.getFloat(i));
break;
case Types.SMALLINT:
System.out.print(Rs.getShort(i));
break;
case Types.TIME:
System.out.print(Rs.getTime(i));
break;
case Types.TIMESTAMP:
System.out.print(Rs.getTimestamp(i));
break;
case Types.TINYINT:
System.out.print(Rs.getByte(i));
break;
case Types.VARBINARY:
System.out.print(Rs.getBytes(i));
break;
case Types.VARCHAR:
System.out.print(Rs.getString(i));
break;
}
System.out.print("\"");
}
System.out.println("");
}
} catch(SQLException e) {
System.out.println(e);
}
}
/********************************************************************
* *
* PreparedStatement Interface: *
* *
* Desc: x *
* *
* Methods: *
* clearParameters setByte setObject *
* execute setBytes setShort *
* executeQuery setDate setString *
* executeUpdate setDouble setTime *
* setAsciiStream setFloat setTimestamp *
* setBigDecimal setInt setUnicodeStream *
* setBinaryStream setLong *
* setBoolean setNull *
* *
*********************************************************************/
void preparedstatement() {
int i;
boolean b;
Connection Db;
PreparedStatement Ds;
ResultSet Rs;
try {
Db = DriverManager.getConnection(DBNAME, DBUSER, DBPSWD);
Ds = Db.prepareStatement("SELECT * FROM options WHERE OptionName = ?");
Ds.setString(1, "TestKey"); // set a parameter to a Java String value
b = Ds.execute();
Rs = Ds.getResultSet();
Rs.close();
Ds.close();
Ds = Db.prepareStatement("SELECT * FROM options WHERE OptionName = ?");
Ds.setString(1, "TestKey");
Rs = Ds.executeQuery(); // query is executed and its ResultSet is returned
Rs.close();
Ds.close();
Ds = Db.prepareStatement("UPDATE options SET OptionValue = ? WHERE OptionName = 'TestKey'");
Ds.setString(1, "Fred");
i = Ds.executeUpdate(); // execute a SQL INSERT, UPDATE or DELETE statement
Ds.close();
} catch(SQLException e) {
System.out.println(e);
}
/*
clearParameters() // In general, parameter values remain in force for repeated use of a Statement.
setAsciiStream(int, InputStream, int) // When a very large ASCII value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.InputStream.
setBigDecimal(int, BigDecimal) // Set a parameter to a java.lang.BigDecimal value.
setBinaryStream(int, InputStream, int) // When a very large binary value is input to a LONGVARBINARY parameter, it may be more practical to send it via a java.io.InputStream.
setBoolean(int, boolean) // Set a parameter to a Java boolean value.
setByte(int, byte) // Set a parameter to a Java byte value.
setBytes(int, byte[]) // Set a parameter to a Java array of bytes.
setDate(int, Date) // Set a parameter to a java.sql.Date value.
setDouble(int, double) // Set a parameter to a Java double value.
setFloat(int, float) // Set a parameter to a Java float value.
setInt(int, int) // Set a parameter to a Java int value.
setLong(int, long) // Set a parameter to a Java long value.
setNull(int, int) // Set a parameter to SQL NULL.
setObject(int, Object) // Set the value of a parameter using an object; use the java.lang equivalent objects for integral values.
setObject(int, Object, int) // This method is like setObject above, but assumes a scale of zero.
setObject(int, Object, int, int) // Set the value of a parameter using an object; use the java.lang equivalent objects for integral values.
setShort(int, short) // Set a parameter to a Java short value.
setTime(int, Time) // Set a parameter to a java.sql.Time value.
setTimestamp(int, Timestamp) // Set a parameter to a java.sql.Timestamp value.
setUnicodeStream(int, InputStream, int) // When a very large UNICODE value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.InputStream.
*/
}
/*********************************************************************
* *
* CallableStatement Interface: *
* *
* Desc: Call stored procedure with out or inout parameter *
* *
* Methods: *
* getBigDecimal getFloat getTime *
* getBoolean getInt getTimestamp *
* getByte getLong registerOutParameter *
* getBytes getObject registerOutParameter *
* getDate getShort wasNull *
* getDouble getString *
* *
*********************************************************************/
void callablestatement() {
/*
getBigDecimal(int, int) // Get the value of a NUMERIC parameter as a java.math.BigDecimal object.
getBoolean(int) // Get the value of a BIT parameter as a Java boolean.
getByte(int) // Get the value of a TINYINT parameter as a Java byte.
getBytes(int) // Get the value of a SQL BINARY or VARBINARY parameter as a Java byte[]
getDate(int) // Get the value of a SQL DATE parameter as a java.sql.Date object
getDouble(int) // Get the value of a DOUBLE parameter as a Java double.
getFloat(int) // Get the value of a FLOAT parameter as a Java float.
getInt(int) // Get the value of an INTEGER parameter as a Java int.
getLong(int) // Get the value of a BIGINT parameter as a Java long.
getObject(int) // Get the value of a parameter as a Java object.
getShort(int) // Get the value of a SMALLINT parameter as a Java short.
getString(int) // Get the value of a CHAR, VARCHAR, or LONGVARCHAR parameter as a Java String.
getTime(int) // Get the value of a SQL TIME parameter as a java.sql.Time object.
getTimestamp(int) // Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.
registerOutParameter(int, int) // Before executing a stored procedure call, you must explicitly call registerOutParameter to register the java.sql.Type of each out parameter.
registerOutParameter(int, int, int) // Use this version of registerOutParameter for registering Numeric or Decimal out parameters.
wasNull() // An OUT parameter may have the value of SQL NULL; wasNull reports whether the last value read has this special value.
*/
}
/*********************************************************************
* *
* Date: *
* *
* Desc: x *
* *
* Methods: *
* getHours setHours setTime *
* getMinutes setMinutes toString *
* getSeconds setSeconds valueOf *
* *
*********************************************************************/
void date() {
/*
getHours() // Returns the hour represented by this date.
getMinutes() // Returns the number of minutes past the hour represented by this date.
getSeconds() // Returns the number of seconds past the minute represented by this date.
setHours(int) // Sets the hour of this date to the specified value.
setMinutes(int) // Sets the minutes of this date to the specified value.
setSeconds(int) // Sets the seconds of this date to the specified value.
setTime(long) // Set a Date using a milliseconds time value
toString() // Format a date in JDBC date escape format
valueOf(String) // Convert a string in JDBC date escape format to a Date value
*/
}
/*********************************************************************
* *
* Time: *
* *
* Desc: x *
* *
* Methods: *
* getDate setDate toString *
* getDay setMonth valueOf *
* getMonth setTime *
* getYear setYear *
* *
*********************************************************************/
void time() {
/*
getDate() // Returns the day of the month represented by this date.
getDay() // Returns the day of the week represented by this date.
getMonth() // Returns the month represented by this date.
getYear() // Returns the year represented by this date, minus 1900.
setDate(int) // Sets the day of the month of this date to the specified value.
setMonth(int) // Sets the month of this date to the specified value.
setTime(long) // Set a Time using a milliseconds time value
setYear(int) // Sets the year of this date to be the specified value plus 1900.
toString() // Format a time in JDBC date escape format
valueOf(String) // Convert a string in JDBC time escape format to a Time value
*/
}
/*********************************************************************
* *
* Timestamp: *
* *
* Desc: x *
* *
* Methods: *
* after getNanos valueOf *
* before setNanos *
* equals toString *
* *
*********************************************************************/
void timestamp() {
/*
after(Timestamp) // Is this timestamp later than the timestamp argument?
before(Timestamp) // Is this timestamp earlier than the timestamp argument?
equals(Timestamp) // Test Timestamp values for equality
getNanos() // Get the Timestamp's nanos value
setNanos(int) // Set the Timestamp's nanos value
toString() // Format a timestamp in JDBC timestamp escape format
valueOf(String) // Convert a string in JDBC timestamp escape format to a Timestamp value
*/
}
/*********************************************************************
* *
* DatabaseMetaData Interface: *
* *
* Desc: x *
* *
* Vars: *
* bestRowNotPseudo procedureColumnUnknown *
* bestRowPseudo procedureNoNulls *
* bestRowSession procedureNoResult *
* bestRowTemporary procedureNullable *
* bestRowTransaction procedureNullableUnknown *
* bestRowUnknown procedureResultUnknown *
* columnNoNulls procedureReturnsResult *
* columnNullable tableIndexClustered *
* columnNullableUnknown tableIndexHashed *
* importedKeyCascade tableIndexOther *
* importedKeyInitiallyDeferred tableIndexStatistic *
* importedKeyInitiallyImmediate typeNoNulls *
* importedKeyNoAction typeNullable *
* importedKeyNotDeferrable typeNullableUnknown *
* importedKeyRestrict typePredBasic *
* importedKeySetDefault typePredChar *
* importedKeySetNull typePredNone *
* procedureColumnIn typeSearchable *
* procedureColumnInOut versionColumnNotPseudo *
* procedureColumnOut versionColumnPseudo *
* procedureColumnResult versionColumnUnknown *
* procedureColumnReturn *
* *
* Methods: *
* allProceduresAreCallable storesMixedCaseIdentifiers *
* allTablesAreSelectable storesMixedCaseQuotedIdentifiers *
* dataDefinitionCauses- storesUpperCaseIdentifiers *
* TransactionCommit storesUpperCaseQuotedIdentifiers *
* dataDefinitionIgnoredIn- supportsAlterTableWithAddColumn *
* Transactions supportsAlterTableWithDropColumn *
* doesMaxRowSizeIncludeBlobs supportsANSI92EntryLevelSQL *
* getBestRowIdentifier supportsANSI92FullSQL *
* getCatalogs supportsANSI92IntermediateSQL *
* getCatalogSeparator supportsCatalogsInData- *
* getCatalogTerm Manipulation *
* getColumnPrivileges supportsCatalogsInIndex- *
* getColumns Definitions *
* getCrossReference supportsCatalogsInPrivilege- *
* getDatabaseProductName Definitions *
* getDatabaseProductVersion supportsCatalogsInProcedureCalls *
* getDefaultTransaction- supportsCatalogsInTable- *
* Isolation Definitions *
* getDriverMajorVersion supportsColumnAliasing *
* getDriverMinorVersion supportsConvert *
* getDriverName supportsConvert *
* getDriverVersion supportsCoreSQLGrammar *
* getExportedKeys supportsCorrelatedSubqueries *
* getExtraNameCharacters supportsDataDefinitionAndData- *
* getIdentifierQuoteString ManipulationTransactions *
* getImportedKeys supportsDataManipulation- *
* getIndexInfo TransactionsOnly *
* getMaxBinaryLiteralLength supportsDifferentTable- *
* getMaxCatalogNameLength CorrelationNames *
* getMaxCharLiteralLength supportsExpressionsInOrderBy *
* getMaxColumnNameLength supportsExtendedSQLGrammar *
* getMaxColumnsInGroupBy supportsFullOuterJoins *
* getMaxColumnsInIndex supportsGroupBy *
* getMaxColumnsInOrderBy supportsGroupByBeyondSelect *
* getMaxColumnsInSelect supportsGroupByUnrelated *
* getMaxColumnsInTable supportsIntegrityEnhancement- *
* getMaxConnections Facility *
* getMaxCursorNameLength supportsLikeEscapeClause *
* getMaxIndexLength supportsLimitedOuterJoins *
* getMaxProcedureNameLength supportsMinimumSQLGrammar *
* getMaxRowSize supportsMixedCaseIdentifiers *
* getMaxSchemaNameLength supportsMixedCaseQuoted- *
* getMaxStatementLength Identifiers *
* getMaxStatements supportsMultipleResultSets *
* getMaxTableNameLength supportsMultipleTransactions *
* getMaxTablesInSelect supportsNonNullableColumns *
* getMaxUserNameLength supportsOpenCursorsAcrossCommit *
* getNumericFunctions supportsOpenCursorsAcross- *
* getPrimaryKeys Rollback *
* getProcedureColumns supportsOpenStatementsAcross- *
* getProcedures Commit *
* getProcedureTerm supportsOpenStatementsAcross- *
* getSchemas Rollback *
* getSchemaTerm supportsOrderByUnrelated *
* getSearchStringEscape supportsOuterJoins *
* getSQLKeywords supportsPositionedDelete *
* getStringFunctions supportsPositionedUpdate *
* getSystemFunctions supportsSchemasInDataManipulation*
* getTablePrivileges supportsSchemasInIndexDefinitions*
* getTables supportsSchemasInPrivilege- *
* getTableTypes Definitions *
* getTimeDateFunctions supportsSchemasInProcedureCalls *
* getTypeInfo supportsSchemasInTableDefinitions*
* getURL supportsSelectForUpdate *
* getUserName supportsStoredProcedures *
* getVersionColumns supportsSubqueriesInComparisons *
* isCatalogAtStart supportsSubqueriesInExists *
* isReadOnly supportsSubqueriesInIns *
* nullPlusNonNullIsNull supportsSubqueriesInQuantifieds *
* nullsAreSortedAtEnd supportsTableCorrelationNames *
* nullsAreSortedAtStart supportsTransactionIsolationLevel*
* nullsAreSortedHigh supportsTransactions *
* nullsAreSortedLow supportsUnion *
* storesLowerCaseIdentifiers supportsUnionAll *
* storesLowerCaseQuoted- usesLocalFilePerTable *
* Identifiers usesLocalFiles *
* *
*********************************************************************/
void databasemetadata() {
int i;
boolean b;
String s;
Connection Db;
DatabaseMetaData Dm;
ResultSet Rs;
try {
Db = DriverManager.getConnection(DBNAME, DBUSER, DBPSWD);
Dm = Db.getMetaData();
b = Dm.allProceduresAreCallable();
b = Dm.allTablesAreSelectable();
b = Dm.dataDefinitionCausesTransactionCommit();
b = Dm.dataDefinitionIgnoredInTransactions();
b = Dm.doesMaxRowSizeIncludeBlobs();
if (DBSERVER) {
Rs = Dm.getBestRowIdentifier("Regenit", "", "employee", Dm.bestRowSession, false);
while (Rs.next()) {
switch (Rs.getShort("SCOPE")) {
case Dm.bestRowTemporary:
break;
case Dm.bestRowTransaction:
break;
case Dm.bestRowSession:
break;
}
switch (Rs.getShort("PSEUDO_COLUMN")) {
case Dm.bestRowNotPseudo:
break;
case Dm.bestRowPseudo:
break;
case Dm.bestRowUnknown:
break;
}
}
}
if (!DBSERVER) {
Rs = Dm.getCatalogs(); // this one seems to hold up the server!!!
}
s = Dm.getCatalogSeparator();
s = Dm.getCatalogTerm();
if (DBSERVER) {
Rs = Dm.getColumnPrivileges("Regenit", "", "employee", "");
Rs = Dm.getColumns("Regenit", "", "employee", "");
while (Rs.next()) {
switch (Rs.getInt("NULLABLE")) {
case Dm.columnNoNulls:
break;
case Dm.columnNullable:
break;
case Dm.columnNullableUnknown:
break;
}
}
Rs = Dm.getCrossReference("Regenit", "", "employee", "Regenit", "", "medical");
while (Rs.next()) {
switch (Rs.getShort("UPDATE_RULE")) {
case Dm.importedKeyNoAction:
break;
case Dm.importedKeyCascade:
break;
case Dm.importedKeySetNull:
break;
case Dm.importedKeySetDefault:
break;
case Dm.importedKeyRestrict:
break;
}
switch (Rs.getShort("DELETE_RULE")) {
case Dm.importedKeyNoAction:
break;
case Dm.importedKeyCascade:
break;
case Dm.importedKeySetNull:
break;
case Dm.importedKeyRestrict:
break;
case Dm.importedKeySetDefault:
break;
}
switch (Rs.getShort("DEFERRABILITY")) {
case Dm.importedKeyInitiallyDeferred:
break;
case Dm.importedKeyInitiallyImmediate:
break;
case Dm.importedKeyNotDeferrable:
break;
}
}
}
s = Dm.getDatabaseProductName();
s = Dm.getDatabaseProductVersion();
i = Dm.getDefaultTransactionIsolation();
i = Dm.getDriverMajorVersion();
i = Dm.getDriverMinorVersion();
s = Dm.getDriverName();
s = Dm.getDriverVersion();
if (DBSERVER) {
Rs = Dm.getExportedKeys("Regenit", "", "employee");
while (Rs.next()) {
switch (Rs.getShort("UPDATE_RULE")) {
case Dm.importedKeyNoAction:
break;
case Dm.importedKeyCascade:
break;
case Dm.importedKeySetNull:
break;
case Dm.importedKeySetDefault:
break;
case Dm.importedKeyRestrict:
break;
}
switch (Rs.getShort("DELETE_RULE")) {
case Dm.importedKeyNoAction:
break;
case Dm.importedKeyCascade:
break;
case Dm.importedKeySetNull:
break;
case Dm.importedKeyRestrict:
break;
case Dm.importedKeySetDefault:
break;
}
switch (Rs.getShort("DEFERRABILITY")) {
case Dm.importedKeyInitiallyDeferred:
break;
case Dm.importedKeyInitiallyImmediate:
break;
case Dm.importedKeyNotDeferrable:
break;
}
}
}
if (!DBSERVER) {
s = Dm.getExtraNameCharacters(); // throws an exception!!!
}
s = Dm.getIdentifierQuoteString();
if (DBSERVER) {
Rs = Dm.getImportedKeys("Regenit", "", "employee");
while (Rs.next()) {
switch (Rs.getShort("UPDATE_RULE")) {
case Dm.importedKeyNoAction:
break;
case Dm.importedKeyCascade:
break;
case Dm.importedKeySetNull:
break;
case Dm.importedKeySetDefault:
break;
case Dm.importedKeyRestrict:
break;
}
switch (Rs.getShort("DELETE_RULE")) {
case Dm.importedKeyNoAction:
break;
case Dm.importedKeyCascade:
break;
case Dm.importedKeySetNull:
break;
case Dm.importedKeyRestrict:
break;
case Dm.importedKeySetDefault:
break;
}
switch (Rs.getShort("DEFERRABILITY")) {
case Dm.importedKeyInitiallyDeferred:
break;
case Dm.importedKeyInitiallyImmediate:
break;
case Dm.importedKeyNotDeferrable:
break;
}
}
Rs = Dm.getIndexInfo("Regenit", "", "employee", false, false);
while (Rs.next()) {
switch (Rs.getShort("TYPE")) {
case Dm.tableIndexStatistic:
break;
case Dm.tableIndexClustered:
break;
case Dm.tableIndexHashed:
break;
case Dm.tableIndexOther:
break;
}
}
}
i = Dm.getMaxBinaryLiteralLength();
i = Dm.getMaxCatalogNameLength();
i = Dm.getMaxCharLiteralLength();
i = Dm.getMaxColumnNameLength();
i = Dm.getMaxColumnsInGroupBy();
i = Dm.getMaxColumnsInIndex();
i = Dm.getMaxColumnsInOrderBy();
i = Dm.getMaxColumnsInSelect();
i = Dm.getMaxColumnsInTable();
i = Dm.getMaxConnections();
i = Dm.getMaxCursorNameLength();
i = Dm.getMaxIndexLength();
i = Dm.getMaxProcedureNameLength();
i = Dm.getMaxRowSize();
i = Dm.getMaxSchemaNameLength();
i = Dm.getMaxStatementLength();
i = Dm.getMaxStatements();
i = Dm.getMaxTableNameLength();
i = Dm.getMaxTablesInSelect();
i = Dm.getMaxUserNameLength();
s = Dm.getNumericFunctions();
if (DBSERVER) {
Rs = Dm.getPrimaryKeys("Regenit", "", "employee");
Rs = Dm.getProcedureColumns("Regenit", "", "employee", "empid");
while (Rs.next()) {
switch (Rs.getShort("COLUMN_TYPE")) {
case Dm.procedureColumnUnknown:
break;
case Dm.procedureColumnIn:
break;
case Dm.procedureColumnInOut:
break;
case Dm.procedureColumnOut:
break;
case Dm.procedureColumnReturn:
break;
case Dm.procedureColumnResult:
break;
}
switch (Rs.getShort("NULLABLE")) {
case Dm.procedureNoNulls:
break;
case Dm.procedureNullable:
break;
case Dm.procedureNullableUnknown:
break;
}
}
Rs = Dm.getProcedures("Regenit", "", "employee");
while (Rs.next()) {
switch (Rs.getShort("PROCEDURE_TYPE")) {
case Dm.procedureResultUnknown:
break;
case Dm.procedureNoResult:
break;
case Dm.procedureReturnsResult:
break;
}
}
}
s = Dm.getProcedureTerm();
// Rs = Dm.getSchemas(); // this one seems to hold up the server!!!
s = Dm.getSchemaTerm();
s = Dm.getSearchStringEscape();
s = Dm.getSQLKeywords();
s = Dm.getStringFunctions();
s = Dm.getSystemFunctions();
if (DBSERVER) {
Rs = Dm.getTablePrivileges("Regenit", "", "employee");
Rs = Dm.getTables("Regenit", "", "employee", null);
}
if (!DBSERVER) {
Rs = Dm.getTableTypes(); // this one seems to hold up the server!!!
}
s = Dm.getTimeDateFunctions();
Rs = Dm.getTypeInfo();
while (Rs.next()) {
switch (Rs.getShort("NULLABLE")) {
case Dm.typeNoNulls:
break;
case Dm.typeNullable:
break;
case Dm.typeNullableUnknown:
break;
}
switch (Rs.getShort("SEARCHABLE")) {
case Dm.typePredNone:
break;
case Dm.typePredChar:
break;
case Dm.typePredBasic:
break;
case Dm.typeSearchable:
break;
}
}
s = Dm.getURL();
s = Dm.getUserName();
if (DBSERVER) {
Rs = Dm.getVersionColumns("Regenit", "", "employee");
while (Rs.next()) {
switch (Rs.getShort("PSEUDO_COLUMN")) {
case Dm.versionColumnUnknown:
break;
case Dm.versionColumnNotPseudo:
break;
case Dm.versionColumnPseudo:
break;
}
}
}
b = Dm.isCatalogAtStart();
b = Dm.isReadOnly();
b = Dm.nullPlusNonNullIsNull();
b = Dm.nullsAreSortedAtEnd();
b = Dm.nullsAreSortedAtStart();
b = Dm.nullsAreSortedHigh();
b = Dm.nullsAreSortedLow();
b = Dm.storesLowerCaseIdentifiers();
b = Dm.storesLowerCaseQuotedIdentifiers();
b = Dm.storesMixedCaseIdentifiers();
b = Dm.storesMixedCaseQuotedIdentifiers();
b = Dm.storesUpperCaseIdentifiers();
b = Dm.storesUpperCaseQuotedIdentifiers();
b = Dm.supportsAlterTableWithAddColumn();
b = Dm.supportsAlterTableWithDropColumn();
b = Dm.supportsANSI92EntryLevelSQL();
b = Dm.supportsANSI92FullSQL();
b = Dm.supportsANSI92IntermediateSQL();
b = Dm.supportsCatalogsInDataManipulation();
b = Dm.supportsCatalogsInIndexDefinitions();
b = Dm.supportsCatalogsInPrivilegeDefinitions();
b = Dm.supportsCatalogsInProcedureCalls();
b = Dm.supportsCatalogsInTableDefinitions();
b = Dm.supportsColumnAliasing();
b = Dm.supportsConvert();
b = Dm.supportsConvert(Types.VARCHAR, Types.CHAR);
b = Dm.supportsCoreSQLGrammar();
b = Dm.supportsCorrelatedSubqueries();
b = Dm.supportsDataDefinitionAndDataManipulationTransactions();
b = Dm.supportsDataManipulationTransactionsOnly();
b = Dm.supportsDifferentTableCorrelationNames();
b = Dm.supportsExpressionsInOrderBy();
b = Dm.supportsExtendedSQLGrammar();
b = Dm.supportsFullOuterJoins();
b = Dm.supportsGroupBy();
b = Dm.supportsGroupByBeyondSelect();
b = Dm.supportsGroupByUnrelated();
b = Dm.supportsIntegrityEnhancementFacility();
b = Dm.supportsLikeEscapeClause();
b = Dm.supportsLimitedOuterJoins();
b = Dm.supportsMinimumSQLGrammar();
b = Dm.supportsMixedCaseIdentifiers();
b = Dm.supportsMixedCaseQuotedIdentifiers();
b = Dm.supportsMultipleResultSets();
b = Dm.supportsMultipleTransactions();
b = Dm.supportsNonNullableColumns();
b = Dm.supportsOpenCursorsAcrossCommit();
b = Dm.supportsOpenCursorsAcrossRollback();
b = Dm.supportsOpenStatementsAcrossCommit();
b = Dm.supportsOpenStatementsAcrossRollback();
b = Dm.supportsOrderByUnrelated();
b = Dm.supportsOuterJoins();
b = Dm.supportsPositionedDelete();
b = Dm.supportsPositionedUpdate();
b = Dm.supportsSchemasInDataManipulation();
b = Dm.supportsSchemasInIndexDefinitions();
b = Dm.supportsSchemasInPrivilegeDefinitions();
b = Dm.supportsSchemasInProcedureCalls();
b = Dm.supportsSchemasInTableDefinitions();
b = Dm.supportsSelectForUpdate();
b = Dm.supportsStoredProcedures();
b = Dm.supportsSubqueriesInComparisons();
b = Dm.supportsSubqueriesIn