public class OracleConnections extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ORACLE_DEFAULT_DRIVER
Default Oracle JDBC driver class.
|
static String |
ORACLE_OCI8_JDBC
Connection String prefix for the Oracle OCI8 (type 2) JDBC driver.
|
static String |
ORACLE_THIN_JDBC
Connection String prefix for the Oracle thin (type 4) JDBC driver.
|
Constructor and Description |
---|
OracleConnections() |
Modifier and Type | Method and Description |
---|---|
static Connection |
getConnection(String user,
String password,
String databaseUrl)
Returns a JDBC Connection to an Oracle database.
|
static Connection |
getConnection(String user,
String password,
String databaseUrl,
String connectAsRole)
Returns a JDBC Connection to an Oracle database.
|
static Connection |
getOci8Connection(String user,
String password,
String connectString)
Returns an OCI8 JDBC Connection to an Oracle database.
|
static Connection |
getOci8Connection(String user,
String password,
String connectString,
String connectAsRole)
Returns an OCI8 JDBC Connection to an Oracle database.
|
static Connection |
getThinConnection(String user,
String password,
String connectString)
Returns a thin JDBC Connection to an Oracle database.
|
static Connection |
getThinConnection(String user,
String password,
String connectString,
String connectAsRole)
Returns a thin JDBC Connection to an Oracle database.
|
public static final String ORACLE_DEFAULT_DRIVER
public static final String ORACLE_THIN_JDBC
public static final String ORACLE_OCI8_JDBC
public static Connection getConnection(String user, String password, String databaseUrl) throws ClassNotFoundException, SQLException
Note: this method attempts to load (dynamically) the class
oracle.jdbc.driver.OracleDriver
using
the method Class.forName()
.
user
- the Oracle database user to authenticate as.password
- the user's password.databaseUrl
- the database URL, which must include the connection
type (OCI8 or thin) and either a TNS connect string
(for OCI8 connections) or host:port:sid (for thin
connections).LinkageError
- if the native part of the driver can't be loaded.ExceptionInInitializerError
- if the initialization
of the OracleDriver class fails.ClassNotFoundException
- if class OracleDriver can't be found.SQLException
public static Connection getConnection(String user, String password, String databaseUrl, String connectAsRole) throws ClassNotFoundException, SQLException
Note: this method attempts to load (dynamically) the class
oracle.jdbc.driver.OracleDriver
using
the method Class.forName()
.
user
- the Oracle database user to authenticate as.password
- the user's password.databaseUrl
- the database URL, which must include the connection
type (OCI8 or thin) and either a TNS connect string
(for OCI8 connections) or host:port:sid (for thin
connections).connectAsRole
- The role used to connect this user. e.g. SYSDBALinkageError
- if the native part of the driver can't be loaded.ExceptionInInitializerError
- if the initialization
of the OracleDriver class fails.ClassNotFoundException
- if class OracleDriver can't be found.SQLException
public static Connection getOci8Connection(String user, String password, String connectString) throws ClassNotFoundException, SQLException
Note: this method attempts to load (dynamically) the class
oracle.jdbc.driver.OracleDriver
using
the method Class.forName()
.
user
- the Oracle database user to authenticate as.password
- the user's password.connectString
- the TNS connect string, or TNS alias (use ""
to specify a local database).LinkageError
- if the native part of the driver can't be loaded.ExceptionInInitializerError
- if the initialization
of the OracleDriver class fails.ClassNotFoundException
- if class OracleDriver can't be found.SQLException
public static Connection getOci8Connection(String user, String password, String connectString, String connectAsRole) throws ClassNotFoundException, SQLException
Note: this method attempts to load (dynamically) the class
oracle.jdbc.driver.OracleDriver
using
the method Class.forName()
.
user
- the Oracle database user to authenticate as.password
- the user's password.connectString
- the TNS connect string, or TNS alias (use ""
to specify a local database).connectAsRole
- The role used to connect this user. e.g. SYSDBALinkageError
- if the native part of the driver can't be loaded.ExceptionInInitializerError
- if the initialization
of the OracleDriver class fails.ClassNotFoundException
- if class OracleDriver can't be found.SQLException
public static Connection getThinConnection(String user, String password, String connectString) throws ClassNotFoundException, SQLException
Note: this method attempts to load (dynamically) the class
oracle.jdbc.driver.OracleDriver
using
the method Class.forName()
.
user
- the Oracle database user to authenticate as.password
- the user's password.connectString
- a String of the form: "host:port:sid", specifying
a database to connect to.ExceptionInInitializerError
- if the initialization
of the OracleDriver class fails.ClassNotFoundException
- if class OracleDriver can't be found.SQLException
public static Connection getThinConnection(String user, String password, String connectString, String connectAsRole) throws ClassNotFoundException, SQLException
Note: this method attempts to load (dynamically) the class
oracle.jdbc.driver.OracleDriver
using
the method Class.forName()
.
user
- the Oracle database user to authenticate as.password
- the user's password.connectString
- a String of the form: "host:port:sid", specifying
a database to connect to.connectAsRole
- The role used to connect this user. e.g. SYSDBAExceptionInInitializerError
- if the initialization
of the OracleDriver class fails.ClassNotFoundException
- if class OracleDriver can't be found.SQLException
Copyright © 2023. All rights reserved.