public class OracleDatabase extends Database
Database d=new OracleDatabase("user","password");
d.queryColumn("SELECT foodname FROM food WHERE origin=\"Italy\"")
-> [ "Pizza Romana", "Spaghetti alla Bolognese", "Saltimbocca"]
Database.describe(d.query("SELECT * FROM food WHERE origin=\"Italy\"")
-> foodname |origin |calories |
------------------------------
Pizza Rom|Italy |10000 |
Spaghetti|Italy |8000 |
Saltimboc|Italy |8000 |
This class also provides SQL datatypes (extensions of SQLType.java) that
behave according to the conventions of Oracle. For example, the ANSI SQL datatype
BOOLEAN is mapped to NUMBER(1). Furthermore, VARCHAR string literals print
inner quotes as doublequotes.
Oracle (and only Oracle!) often complains "ORA-01000: maximum open cursors exceeded". This does not necessarily mean that the maximum number of open cursors is exceeded. It can also mean that your SQL statement has an invalid character. Check your SQL statements carefully. If the statements are OK, try the following:
| Modifier and Type | Class and Description |
|---|---|
static class |
OracleDatabase.Bigint |
static class |
OracleDatabase.Bool |
static class |
OracleDatabase.Varchar |
Database.CommitTransactionSQLException, Database.ConnectionBrokenSQLException, Database.InitTransactionSQLException, Database.Inserter, Database.RollbackTransactionSQLException, Database.StartAutoCommitSQLException, Database.TransactionSQLException| Modifier and Type | Field and Description |
|---|---|
static OracleDatabase.Bigint |
bigint |
static OracleDatabase.Bool |
bool |
protected String |
connectionString
Holds the String by which the connection can be reset
|
static OracleDatabase.Varchar |
varchar |
connection, description, driver, fetchsize, inserters, java2SQL, MINCOLUMNWIDTH, resultSetConcurrency, resultSetType, SCREENWIDTH, type2SQL| Constructor and Description |
|---|
OracleDatabase()
Constructs a non-functional OracleDatabase for use of getSQLType
|
OracleDatabase(String user,
String password)
Constructs a new OracleDatabase from a user and a password on the localhost
|
OracleDatabase(String user,
String password,
String host)
Constructs a new OracleDatabase from a user, a password and a host
|
OracleDatabase(String user,
String password,
String host,
String port)
Constructs a new OracleDatabase from a user, a password and a host
|
OracleDatabase(String user,
String password,
String host,
String port,
String inst)
Constructs a new OracleDatabase from a user, a password and a host
|
| Modifier and Type | Method and Description |
|---|---|
void |
connect()
connects to the database specified
|
boolean |
connected()
Checks whether the connection to the database is still alive
|
boolean |
jarAvailable()
TRUE if the required JAR is there
|
String |
limit(String sql,
int n)
Makes an SQL query limited to n results
|
static void |
main(String[] args) |
protected String |
prepareQuery(String sql)
Prepares the query internally for a call (deletes trailing semicolon)
|
void |
resetConnection()
Deprecated.
replaced by
Database.reconnect() |
appendFixedLen, attemptReconnect, autoincrementColumn, cast, close, close, close, close, commitTransaction, createIndex, createIndexCommand, createIndices, createPrimaryKey, createTable, createView, describe, describe, dumpCSV, dumpQueryAsCSV, endTransaction, endTransaction, executeQuery, executeUpdate, executeUpdateQuery, exists, existsTable, finalize, flush, format, formatNullToNull, getConnection, getFetchsize, getResultSetConcurrency, getResultSetType, getSQLStmntIFNULL, getSQLType, getSQLType, getSQLType, getValidityCheckTimeout, indexName, isAutoReconnectingOnSelect, isAutoReconnectingOnUpdate, loadCSV, lockTableReadAccess, lockTableWriteAccess, makeCSV, makeCSVForQuery, newInserter, newInserter, newInserter, offset, query, query, query, query, queryValue, reconnect, releaseLocksAndEndTransaction, resetTransaction, runInterface, setAutoReconnectOnSelect, setAutoReconnectOnUpdate, setFetchsize, setResultSetConcurrency, setResultSetType, setValidityCheckTimeout, startTransaction, toStringprotected String connectionString
public static OracleDatabase.Varchar varchar
public static OracleDatabase.Bool bool
public static OracleDatabase.Bigint bigint
public OracleDatabase()
public OracleDatabase(String user, String password, String host) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
public OracleDatabase(String user, String password, String host, String port) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
public OracleDatabase(String user, String password, String host, String port, String inst) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
protected String prepareQuery(String sql)
prepareQuery in class Database@Deprecated public void resetConnection() throws SQLException
Database.reconnect()SQLExceptionpublic void connect()
throws SQLException
connect in class DatabaseSQLExceptionpublic boolean jarAvailable()
DatabasejarAvailable in class Databasepublic boolean connected()
public static void main(String[] args)
Copyright © 2018. All rights reserved.