本文整理汇总了Java中oracle.jdbc.OracleConnection类的典型用法代码示例。如果您正苦于以下问题:Java OracleConnection类的具体用法?Java OracleConnection怎么用?Java OracleConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OracleConnection类属于oracle.jdbc包,在下文中一共展示了OracleConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
/**
* This method is an extension to the similarly named method of the base class.
* It acquires a Connection by invoking the connect() method of the base class.
* It stamps the following properties on the Connection, which is not the case in the base class (as of Oracle JDBC Driver version - "10.2.0.3.0")
* - stmt_cache_size
* - ImplicitStatementCachingEnabled
* @param url the URL of the database to which to connect.
* @param info a list of arbitrary string tag/value pairs as connection arguments. Normally at least a "user" and "password" property should be included.
* @return a Connection object that represents a connection to the URL.
* @throws SQLException if a database access error occurs.
*/
@Override
public Connection connect(String url, Properties info) throws SQLException {
if (log.isDebugEnabled())
log.debug("Acquiring Connection with url='" + url + "' and properties=" + info);
Connection connection = super.connect(url, info);
if (connection != null && info != null) {
String s;
s = info.getProperty("stmt_cache_size");
if (s != null)
((OracleConnection) connection).setStatementCacheSize(Integer.parseInt(s));
s = info.getProperty("ImplicitStatementCachingEnabled");
if (s != null)
((OracleConnection) connection).setImplicitCachingEnabled(s.equals("true"));
}
return connection;
}
示例2: createSQLArrayVarchar
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
/**
* Essa funcao serve para converer um array em Um aray SQL
* @param array O array a ser convertido para o array de base de dados
* @param connect A conexao que sera usada
* @param arrayTypeDataBase nome do aray na base de dados que ira receber o aray
* CASO for nulo sera mapeado para o TB_ARRAY_STRING
* @return
*/
public static Array createSQLArrayVarchar (Object [] array, Connection connect, String arrayTypeDataBase)
{
try
{
arrayTypeDataBase = (arrayTypeDataBase == null)? "TB_ARRAY_STRING": arrayTypeDataBase;
ArrayDescriptor arryDesc = ArrayDescriptor.createDescriptor(arrayTypeDataBase, connect);
Array oracleArray = new ARRAY(arryDesc, connect, array);
OracleConnection oc = (OracleConnection) connect;
return oracleArray;
} catch (SQLException ex) {
ex.printStackTrace();
}
return null;
}
示例3: getTemporaryClob
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
public final CLOB getTemporaryClob() {
checkOpen();
CLOB lCLOB;
try {
lCLOB = CLOB.createTemporary(
mDatabaseConnection.unwrap(OracleConnection.class)
, true /*isCached*/
, CLOB.DURATION_SESSION /* Only duration_session in client side java applications */
);
}
catch (SQLException e) {
throw new ExInternal("Temporary clob cannot be created", e);
}
return lCLOB;
}
示例4: processTestConnectionRequest
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
private static void processTestConnectionRequest(FoxRequest pFoxRequest) {
boolean lIsConnectionSuccess = false;
try {
OracleConnection lConnection = getDatabaseConnectionFromRequest(pFoxRequest.getHttpRequest());
lConnection.close();
lIsConnectionSuccess = true;
}
catch (ExInternalConfiguration | SQLException e) {
createJsonError("Connection test failed: " + e.getMessage()).respond(pFoxRequest);
}
JSONObject lJSONConnectionResult = new JSONObject();
lJSONConnectionResult.put("status", lIsConnectionSuccess ? "success" : "failure");
new FoxResponseCHAR("application/json", new StringBuffer(lJSONConnectionResult.toJSONString()), 0).respond(pFoxRequest);
}
示例5: convertGeometry
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
@Override
public JdbcChangeValue convertGeometry(String aValue, Connection aConnection) throws SQLException {
if (!(aConnection instanceof OracleConnection)) {
aConnection = aConnection.unwrap(OracleConnection.class);
}
try {
GeometryConverter gc = new GeometryConverter((OracleConnection) aConnection);
JdbcChangeValue jdbcValue = new JdbcChangeValue(null, null, 0, null);
WKTReader reader = new WKTReader();
jdbcValue.value = aValue != null ? gc.toSDO(reader.read(aValue)) : null;
jdbcValue.jdbcType = Types.STRUCT;
jdbcValue.sqlTypeName = "MDSYS.SDO_GEOMETRY";
return jdbcValue;
} catch (ParseException ex) {
throw new SQLException(ex);
}
}
示例6: getProxyConnection
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
/**
* returns a proxy database connection.
*
* @param ds
* @param dataId
* @return
* @throws SQLException
*/
public static Connection getProxyConnection(DataSource ds,
DataIdentifier dataId) throws SQLException {
Connection conn = ds.getConnection();
//for OracleConnection
if (((DelegatingConnection) conn).getInnermostDelegate() instanceof OracleConnection) {
Properties properties = getOracleProxyConnectionProperties(dataId);
OracleConnection oracleConnection = (OracleConnection) ((DelegatingConnection) conn).getInnermostDelegate();
oracleConnection.openProxySession(OracleConnection.PROXYTYPE_USER_NAME,
properties);
conn = oracleConnection;
}
return conn;
}
示例7: getMdTableHashcode
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
private Integer getMdTableHashcode(OracleConnection conn, MdTable t) throws SQLException {
StringBuilder sb = new StringBuilder();
try (PreparedStatement ps = conn.prepareStatement(t.getSql())) {
ResultSetMetaData md = ps.getMetaData();
for (int c = 1; c <= md.getColumnCount(); c++) {
sb.append(md.getColumnName(c))
.append(" ")
.append(md.getColumnTypeName(c))
.append("(")
.append(md.getScale(c))
.append(",")
.append(md.getPrecision(c))
.append(");");
}
}
return sb.toString().hashCode();
}
示例8: Insersor
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
public Insersor(String host, String sid, String user, String password, List<String> lines) {
try {
Class.forName("oracle.jdbc.OracleDriver");
this.connection = (OracleConnection) DriverManager.getConnection("jdbc:oracle:thin:@" + host + ":1521:" + sid,
user, password);
} catch (Exception e) {
}
this.lines = lines;
}
示例9: executeQuery
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
public ResultSet executeQuery(String sql, String host, String sid, String usuario, String senha)
throws SQLException, ClassNotFoundException {
Class.forName("oracle.jdbc.OracleDriver");
this.connection = (OracleConnection) DriverManager.getConnection("jdbc:oracle:thin:@" + host + ":1521:" + sid,
usuario, senha);
PreparedStatement statement = (PreparedStatement) this.connection.prepareCall(sql);
return statement.executeQuery();
}
示例10: wrapOracleConnection
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
public static Connection wrapOracleConnection(Connection con) {
if( con == null ) {
return null;
}
if( con instanceof WrappedOracleConnection) {
return con;
}
if( con instanceof OracleConnection ) {
return new WrappedOracleConnection(con);
}
return new WrappedConnection(con);
}
示例11: getConnection
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
public OracleConnection getConnection() throws SQLException{
final OracleDriver oracleDriver = new OracleDriver();
Properties oracleProperties = new Properties();
oracleProperties.put("user", getUserName());
oracleProperties.put("password", getPassword());
return (OracleConnection)oracleDriver.connect(getConnectionString(), oracleProperties);
}
示例12: convertClobToSQLXML
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
public SQLXML convertClobToSQLXML(Clob pClob) {
//TODO make database agnostic
try {
return XMLType.createXML(mDatabaseConnection.unwrap(OracleConnection.class), (CLOB) pClob);
}
catch(SQLException e) {
throw new ExInternal("XMLType can not be created",e);
}
}
示例13: getTemporaryBlob
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
public final BLOB getTemporaryBlob() {
checkOpen();
BLOB lBLOB;
try {
lBLOB = BLOB.createTemporary(
mDatabaseConnection.unwrap(OracleConnection.class)
, true /*isCached*/
, BLOB.DURATION_SESSION /* Only duration_session in client side java applications */
);
}
catch (SQLException e) {
throw new ExInternal("Temporary blob cannot be created", e);
}
return lBLOB;
}
示例14: getDatabaseConnectionFromRequest
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
private static OracleConnection getDatabaseConnectionFromRequest(HttpServletRequest pRequest) throws ExInternalConfiguration {
String lDBURL = pRequest.getParameter("db_url");
String lDBUsername = pRequest.getParameter("db_user");
String lDBPassword = getUpdatedDatabaseUserPassword(lDBUsername, pRequest.getParameter("db_password"));
return getDatabaseConnection(lDBURL, lDBUsername, lDBPassword);
}
示例15: getDatabaseConnection
import oracle.jdbc.OracleConnection; //导入依赖的package包/类
/**
* Returns an open and valid connection for the given database details. If the connection could not be opened an
* exception is raised. If the connection was opened but is not valid, the connection is closed and an exception is
* raised.
* @param pDBURL
* @param pDBUsername
* @param pDBPassword
* @return
*/
private static OracleConnection getDatabaseConnection(String pDBURL, String pDBUsername, String pDBPassword) throws ExInternalConfiguration {
if (XFUtil.isNull(pDBURL) || XFUtil.isNull(pDBUsername) || XFUtil.isNull(pDBPassword)) {
throw new ExInternalConfiguration("You must provide a database URL, username and password to connect.");
}
OracleDriver lDriver = new OracleDriver();
Properties lProperties = new Properties();
lProperties.setProperty("user", pDBUsername);
lProperties.setProperty("password", pDBPassword);
try {
OracleConnection lConnection = (OracleConnection) lDriver.connect("jdbc:oracle:thin:@" + pDBURL, lProperties);
if (lConnection == null) {
throw new ExInternalConfiguration("Connection could not be opened as the database driver cannot open the URL");
}
if (!lConnection.isValid(TEST_CONNECTION_VALID_TIMEOUT_MS)) {
lConnection.close();
throw new ExInternalConfiguration("Connection opened but is not valid after "
+ TimeUnit.MILLISECONDS.toSeconds(TEST_CONNECTION_VALID_TIMEOUT_MS)
+ " seconds");
}
return lConnection;
}
catch (SQLException e) {
throw new ExInternalConfiguration("Failed to connect. Please check the username / password / service combination is correct. " + e.getMessage() +
(e.getCause() != null ? "\n\nCaused by: " + e.getCause().getMessage() : ""));
}
}