本文整理汇总了Java中oracle.jdbc.pool.OracleDataSource类的典型用法代码示例。如果您正苦于以下问题:Java OracleDataSource类的具体用法?Java OracleDataSource怎么用?Java OracleDataSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OracleDataSource类属于oracle.jdbc.pool包,在下文中一共展示了OracleDataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialSetup
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
public void initialSetup(String rootUser, String rootPass, String rootDb)
{
try
{
// Set up the root connection
OracleDataSource oracleRootSource = new OracleDataSource();
oracleRootSource.setServerName(DatabaseProperties.getServerName());
oracleRootSource.setServiceName(rootDb);
oracleRootSource.setPortNumber(DatabaseProperties.getPort());
oracleRootSource.setDriverType("thin");
oracleRootSource.setUser(rootUser);
oracleRootSource.setPassword(rootPass);
this.rootDataSource = oracleRootSource;
}
catch (SQLException e)
{
throwDatabaseException(e);
}
this.dropUser();
this.createUser();
}
示例2: createConnection
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
public static Connection createConnection() throws SQLException {
MjdbcUtils.loadDriver("oracle.jdbc.pool.OracleDataSource");
OracleDataSource ds = new oracle.jdbc.pool.OracleDataSource();
ds.setDriverType("thin");
ds.setServerName("localhost");
ds.setDatabaseName("xe");
ds.setPortNumber(1521);
ds.setUser("chris");
ds.setPassword("welcome1");
Connection conn = ds.getConnection();
return conn;
}
示例3: dataSource
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
private static HikariDataSource dataSource(PatterdaleRuntimeParameters runtimeParameters, DatabaseDefinition databaseDefinition, Passwords passwords, Logger logger)
throws SQLException {
try {
OracleDataSource oracleDataSource = new OracleDataSource();
oracleDataSource.setUser(databaseDefinition.user);
String password = passwords.byDatabaseName(databaseDefinition.name).value;
oracleDataSource.setPassword(password);
HikariDataSource hikariDataSource = new HikariDataSource(jdbcConfig(runtimeParameters, databaseDefinition, password));
hikariDataSource.setDataSource(oracleDataSource);
return hikariDataSource;
} catch (Exception e) {
logger.error("Error occurred initialising Oracle and Hikari data sources.", e);
throw e; // caught by the RetryPolicy
}
}
示例4: createConnectionPool
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
/**
* Creates a database connection pool object using JDBC 2.0.
*/
private OracleDataSource createConnectionPool() {
try {
// Create a OracleConnectionPoolDataSource instance.
OracleDataSource ds = new OracleDataSource();
ds.setConnectionCacheName("oraCache");
ds.setConnectionCachingEnabled(true);
ds.setURL(TestConfig.tab().stringAt(JtaPrms.jdbcUrl));
ds.setUser(TestConfig.tab().stringAt(JtaPrms.rdbUser));
ds.setPassword(TestConfig.tab().stringAt(JtaPrms.rdbPassword));
Properties cacheProps = new Properties();
cacheProps.setProperty("MinLimit",
String.valueOf(TestConfig.tab().intAt(JtaPrms.poolMinLimit)));
ds.setConnectionCacheProperties(cacheProps);
return ds;
} catch (Exception ex) {
Log.getLogWriter().info("Unable to create connection pool: " + ex, ex);
throw new HydraRuntimeException("Problem creating Oracle connection pool", ex);
}
}
示例5: generate
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
public void generate(Settings settings) {
try {
OracleDataSource oracleDataSource = new OracleDataSource();
oracleDataSource.setURL(settings.getJdbcUrl());
TypeCatalogDAO typeCatalogDAO = new TypeCatalogDAO(oracleDataSource);
List<String> types = typeCatalogDAO.getTypeList();
for (String typeName : types) {
List<TypeAttribute> typeAttributes = typeCatalogDAO.getTypeAttributes(typeName);
String className = StringHelper.toCamelCase(typeName);
VelocityRenderer velocityRenderer = new VelocityRenderer("typepojo.vm");
velocityRenderer.put("className", className);
velocityRenderer.put("targetPackage", settings.getEntityPackageName());
velocityRenderer.put("attrList", typeAttributes);
FileUtils.writeStringToFile(new File(settings.getBasePath() + "/" + settings.getEntityPackageName().replace(".", "/") + "/" + className + ".java"), velocityRenderer.render());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例6: AccessManager
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
public AccessManager(ServletContext context, OracleDataSource ods) {
// This is wasteful for the initial load, but prevents an unreachable database
// Connection from storing a null reference instead of an empty HashMap
permissionMap = new HashMap<String, accessLevel>();
ipAccessList = new HashSet<InetAddress>();
this.ods = ods;
// The only IN Parameter is accessLevel
roleMappingSql = context.getInitParameter("roleMappingSQL");
// IN Parameters are all (accessLevel, username)
updateRoleSql = context.getInitParameter("updateRoleSQL");
addUserSql = context.getInitParameter("addUserSQL");
removeUserSql = context.getInitParameter("removeUserSQL");
try {
this.refresh();
this.refreshAddressList();
}catch (SQLException e){
log.error(e);
}
}
示例7: privilegedBankDataSource
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
@Bean
PrivilegedDataSourceProvider privilegedBankDataSource() throws SQLException {
OracleDataSource dataSource = new OracleDataSource();
dataSource.setUser("system");
dataSource.setPassword("oracle");
dataSource.setURL("jdbc:oracle:thin:@//localhost:1521/XE");
return DefaultPrivilegedDataSourceProvider.builder()
.dataSourceName("dataSource")
.privilegedDataSource(dataSource)
.schemas(Arrays.asList("BANK"))
.build();
}
示例8: Create
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
/**
* Creates a connection to an oracle database
* @param username A username, e.g. "DB_USER"
* @param password A password, e.g. "rainbow123"
* @param connectionString A connection string, e.g. "jdbc:oracle:thin:@sdwh.cooperation.net:1331:SDWH"
* @param log Object for accessing the console
* @return a Connection object
* @throws SQLException
*/
public static Connection Create(String username, String password, String connectionString, Log log) throws SQLException {
PingPong ping = log.info("connecting to database...");
OracleDataSource ods = new OracleDataSource();
ods.setUser(username);
ods.setPassword(password);
ods.setURL(connectionString);
log.finished(ping);
return ods.getConnection();
}
示例9: dataSource
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
@Bean
public OracleDataSource dataSource() throws SQLException {
OracleDataSource ds = new OracleDataSource();
ds.setURL(WqpEnv.get("test.datasource.url"));
ds.setUser(WqpEnv.get("test.datasource.username"));
ds.setPassword(WqpEnv.get("test.datasource.password"));
return ds;
}
示例10: dbUnitDataSource
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
@Bean
public OracleDataSource dbUnitDataSource() throws SQLException {
OracleDataSource ds = new OracleDataSource();
ds.setURL(WqpEnv.get("test.datasource.url"));
ds.setUser(WqpEnv.get("test.dbunit.username"));
ds.setPassword(WqpEnv.get("test.dbunit.password"));
return ds;
}
示例11: getInitialContext
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
public Context getInitialContext(Hashtable<?, ?> arg0) throws NamingException {
Context envContext = Mockito.mock(Context.class);
try {
Mockito.when(envContext.lookup(TEST_JNDI)).thenReturn(new OracleDataSource());
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Context context = Mockito.mock(Context.class);
Mockito.when(context.lookup(CTX_NAME)).thenReturn(envContext);
return context;
}
示例12: ScriptRunner
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
public ScriptRunner(final String jdbcUrl, final String username, final String password) throws SQLException {
OracleDataSource ds = new OracleDataSource();
ds.setURL(jdbcUrl);
ds.setUser(username);
ds.setPassword(password);
this.dataSource = ds;
}
示例13: execute
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
@Override
public void execute(ExecutionState state) throws CommandException {
try {
OracleDataSource dataSource = JdbcUtil.connectToOracle(this);
Connection connection = dataSource.getConnection();
SourceSql src = new OracleSource(connection, state.getDebug());
state.setSourceSql(src);
} catch (SQLException ex) {
throw new CommandException("unable to connect to database", ex);
}
}
示例14: StartConnection
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
private void StartConnection() {
try {
Locale.setDefault(new Locale(stringConnection.language(), stringConnection.country()));
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:@" + stringConnection.host() + ":" + stringConnection.port() + ":" + stringConnection.database());
ods.setUser(stringConnection.user());
ods.setPassword(stringConnection.password());
connection = ods.getConnection();
connection.setAutoCommit(stringConnection.autoCommit());
} catch (SQLException e) {
System.out.println("Could not connect - StartConnection (). Let's try again!");
e.printStackTrace();
StartConnection();
}
}
示例15: generate
import oracle.jdbc.pool.OracleDataSource; //导入依赖的package包/类
public void generate(Settings settings) {
try {
OracleDataSource oracleDataSource = new OracleDataSource();
oracleDataSource.setURL(settings.getJdbcUrl());
ProcedureCatalogDAO procedureCatalogDAO = new ProcedureCatalogDAO(oracleDataSource);
List<Procedure> allProcedures = procedureCatalogDAO.getAllProcedures("");
for (Procedure p : allProcedures) {
List<ProcedureArgument> procedureArguments = procedureCatalogDAO.getProcedureArguments(p.getObjectName(), p.getProcedureName(), p.getOverload());
String className = StringHelper.toCamelCase(p.getObjectName() + "_" + p.getProcedureName() + "_" + p.getOverload());
VelocityRenderer velocityRenderer = new VelocityRenderer("sppojo.vm");
velocityRenderer.put("className", className);
velocityRenderer.put("procedure", p);
velocityRenderer.put("procedureName", p.getObjectName() + "." + p.getProcedureName());
velocityRenderer.put("targetPackage", settings.getProcedurePackageName());
velocityRenderer.put("par", procedureArguments);
velocityRenderer.put("modelPackage", settings.getEntityPackageName());
velocityRenderer.put("converterPackage", settings.getConverterPackageName());
velocityRenderer.put("utilPackage", settings.getUtilPackageName());
FileUtils.writeStringToFile(new File(settings.getBasePath() + "/" + settings.getProcedurePackageName().replace(".", "/") + "/" + className + ".java"), velocityRenderer.render());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}