List of usage examples for java.sql Connection TRANSACTION_REPEATABLE_READ
int TRANSACTION_REPEATABLE_READ
To view the source code for java.sql Connection TRANSACTION_REPEATABLE_READ.
Click Source Link
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public void modifyColumnComment(String dbName, String tblName, String colName, String comment) throws InvalidOperationException, MetaException { Connection con = null;/*from w w w .j a va 2 s.co m*/ PreparedStatement ps = null; boolean success = false; dbName = dbName.toLowerCase(); tblName = tblName.toLowerCase(); try { con = getSegmentConnection(dbName); } catch (MetaStoreConnectException e1) { LOG.error("alter column comment error, db=" + dbName + ", tbl=" + tblName + ", column=" + colName + ", comment=" + comment + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("alter column comment error, db=" + dbName + ", tbl=" + tblName + ", column=" + colName + ", comment=" + comment + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } try { con.setAutoCommit(false); con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); ps = con.prepareStatement("select tbls.tbl_id from tbls, columns where tbls.tbl_id=columns.tbl_id " + " and tbls.db_name=? and tbls.tbl_name=? and columns.column_name=?"); long tblID = 0; boolean isColFind = false; ps.setString(1, dbName); ps.setString(2, tblName); ps.setString(3, colName.toLowerCase()); ResultSet tSet = ps.executeQuery(); while (tSet.next()) { tblID = tSet.getLong(1); isColFind = true; break; } tSet.close(); ps.close(); if (!isColFind) { LOG.error("alter table comment error, db=" + dbName + ", tbl=" + tblName + ", comment=" + comment); throw new MetaException("can not find table/column " + dbName + ":" + tblName + "/" + colName); } ps = con.prepareStatement("update columns set comment=? where tbl_id=? and column_name=?"); ps.setString(1, comment); ps.setLong(2, tblID); ps.setString(3, colName.toLowerCase()); ps.executeUpdate(); con.commit(); success = true; } catch (SQLException sqlex) { LOG.error("alter column comment error, db=" + dbName + ", tbl=" + tblName + ", column=" + colName + ", comment=" + comment + ", msg=" + sqlex.getMessage()); sqlex.printStackTrace(); throw new MetaException(sqlex.getMessage()); } finally { if (!success) { try { con.rollback(); } catch (SQLException e) { } } closeStatement(ps); closeConnection(con); } }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public boolean updatePBInfo(String dbName, String tableName, String modifiedTime) throws InvalidOperationException, MetaException { Connection con = null;// www . j a v a 2 s . com PreparedStatement ps = null; boolean success = false; dbName = dbName.toLowerCase(); tableName = tableName.toLowerCase(); String jarName = "./auxlib/" + dbName + "_" + tableName + "_" + modifiedTime + ".jar"; String className = dbName + "_" + tableName + "_" + modifiedTime; try { con = getSegmentConnection(dbName); } catch (MetaStoreConnectException e1) { LOG.error("updatePBInfo, db=" + dbName + ", table=" + tableName + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("replace column error, db=" + dbName + ", table=" + tableName + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } try { con.setAutoCommit(false); con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); ps = con.prepareStatement("select tbl_id, serde_lib" + " from tbls where db_name=? and tbl_name=?"); ps.setString(1, dbName); ps.setString(2, tableName); String serdeLib = null; boolean isTblFind = false; long tblID = 0; ResultSet tblSet = ps.executeQuery(); while (tblSet.next()) { isTblFind = true; tblID = tblSet.getLong(1); serdeLib = tblSet.getString(2); } tblSet.close(); ps.close(); if (!isTblFind) { throw new MetaException("can not find table " + dbName + ":" + tableName); } if (!serdeLib.equals(ProtobufSerDe.class.getName())) { throw new MetaException("sorry, can only update jar info for a pb table "); } Map<String, String> tblParamMap = new HashMap<String, String>(); ps = con.prepareStatement( "select param_key, param_value from table_params where tbl_id=? and param_type='TBL'"); ps.setLong(1, tblID); ResultSet paramSet = ps.executeQuery(); while (paramSet.next()) { tblParamMap.put(paramSet.getString(1), paramSet.getString(2)); } paramSet.close(); ps.close(); boolean containJar = false; boolean containClass = false; if (tblParamMap.containsKey("pb.jar")) containJar = true; if (tblParamMap.containsKey("pb.outer.class.name")) containClass = true; if (containJar && containClass) { ps = con.prepareStatement( "update table_params set param_value=? where tbl_id=? and param_type='TBL' and param_key=?"); ps.setString(1, jarName); ps.setLong(2, tblID); ps.setString(3, "pb.jar"); ps.addBatch(); ps.setString(1, className); ps.setLong(2, tblID); ps.setString(3, "pb.outer.class.name"); ps.addBatch(); ps.executeBatch(); ps.close(); } con.commit(); success = true; } catch (SQLException ex) { ex.printStackTrace(); LOG.error("updatePBInfo, db=" + dbName + ", tbl=" + tableName + ", msg=" + ex.getMessage()); throw new MetaException(ex.getMessage()); } finally { if (!success) { try { con.rollback(); } catch (SQLException e) { } } closeStatement(ps); closeConnection(con); } return true; }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public boolean isPBTable(String dbName, String tableName) throws MetaException { Connection con = null;// w w w . jav a 2 s . c o m PreparedStatement ps = null; dbName = dbName.toLowerCase(); tableName = tableName.toLowerCase(); try { con = getSegmentConnection(dbName); } catch (MetaStoreConnectException e1) { LOG.error("isPBTable, db=" + dbName + ", table=" + tableName + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("isPBTable error, db=" + dbName + ", table=" + tableName + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } try { con.setAutoCommit(false); con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); ps = con.prepareStatement("select serde_lib" + " from tbls where db_name=? and tbl_name=?"); ps.setString(1, dbName); ps.setString(2, tableName); String serdeLib = null; boolean isTblFind = false; ResultSet tblSet = ps.executeQuery(); while (tblSet.next()) { isTblFind = true; serdeLib = tblSet.getString(1); } tblSet.close(); ps.close(); if (!isTblFind) { throw new MetaException("can not find table " + dbName + ":" + tableName); } closeStatement(ps); closeConnection(con); if (serdeLib.equals(ProtobufSerDe.class.getName())) return true; else return false; } catch (SQLException ex) { ex.printStackTrace(); closeStatement(ps); closeConnection(con); LOG.error("updatePBInfo, db=" + dbName + ", tbl=" + tableName + ", msg=" + ex.getMessage()); throw new MetaException(ex.getMessage()); } }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
@Override public boolean isHdfsExternalTable(String dbName, String tableName) throws MetaException { Connection con = null;//from w w w.j a va 2s.c o m PreparedStatement ps = null; dbName = dbName.toLowerCase(); tableName = tableName.toLowerCase(); try { con = getSegmentConnection(dbName); } catch (MetaStoreConnectException e1) { LOG.error("isHdfsExternalTable error, db=" + dbName + ", table=" + tableName + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } catch (SQLException e1) { LOG.error("isHdfsExternalTable error, db=" + dbName + ", table=" + tableName + ", msg=" + e1.getMessage()); throw new MetaException(e1.getMessage()); } try { con.setAutoCommit(false); con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); ps = con.prepareStatement("select tbl_type, tbl_format" + " from tbls where db_name=? and tbl_name=?"); ps.setString(1, dbName); ps.setString(2, tableName); String tblType = null; String tblFormat = null; boolean isTblFind = false; ResultSet tblSet = ps.executeQuery(); while (tblSet.next()) { isTblFind = true; tblType = tblSet.getString(1); tblFormat = tblSet.getString(2); } tblSet.close(); ps.close(); if (!isTblFind) { throw new MetaException("can not find table " + dbName + ":" + tableName); } closeStatement(ps); closeConnection(con); boolean isPgTable = tblType != null && tblType.equalsIgnoreCase("EXTERNAL_TABLE") && tblFormat != null && tblFormat.equalsIgnoreCase("pgdata"); if (tblType != null && tblType.equalsIgnoreCase("EXTERNAL_TABLE") && !isPgTable) return true; else return false; } catch (SQLException ex) { ex.printStackTrace(); closeStatement(ps); closeConnection(con); LOG.error( "isHdfsExternalTable error, db=" + dbName + ", tbl=" + tableName + ", msg=" + ex.getMessage()); throw new MetaException(ex.getMessage()); } }
From source file:org.apache.ofbiz.entity.connection.DBCPConnectionFactory.java
public Connection getConnection(GenericHelperInfo helperInfo, JdbcElement abstractJdbc) throws SQLException, GenericEntityException { String cacheKey = helperInfo.getHelperFullName(); DebugManagedDataSource mds = dsCache.get(cacheKey); if (mds != null) { return TransactionUtil.getCursorConnection(helperInfo, mds.getConnection()); }// ww w. ja va2 s . co m if (!(abstractJdbc instanceof InlineJdbc)) { throw new GenericEntityConfException( "DBCP requires an <inline-jdbc> child element in the <datasource> element"); } InlineJdbc jdbcElement = (InlineJdbc) abstractJdbc; // connection properties TransactionManager txMgr = TransactionFactoryLoader.getInstance().getTransactionManager(); String driverName = jdbcElement.getJdbcDriver(); String jdbcUri = helperInfo.getOverrideJdbcUri(jdbcElement.getJdbcUri()); String jdbcUsername = helperInfo.getOverrideUsername(jdbcElement.getJdbcUsername()); String jdbcPassword = helperInfo.getOverridePassword(EntityConfig.getJdbcPassword(jdbcElement)); // pool settings int maxSize = jdbcElement.getPoolMaxsize(); int minSize = jdbcElement.getPoolMinsize(); int maxIdle = jdbcElement.getIdleMaxsize(); // maxIdle must be greater than pool-minsize maxIdle = maxIdle > minSize ? maxIdle : minSize; // load the driver Driver jdbcDriver; synchronized (DBCPConnectionFactory.class) { // Sync needed for MS SQL JDBC driver. See OFBIZ-5216. try { jdbcDriver = (Driver) Class .forName(driverName, true, Thread.currentThread().getContextClassLoader()).newInstance(); } catch (Exception e) { Debug.logError(e, module); throw new GenericEntityException(e.getMessage(), e); } } // connection factory properties Properties cfProps = new Properties(); cfProps.put("user", jdbcUsername); cfProps.put("password", jdbcPassword); // create the connection factory org.apache.commons.dbcp2.ConnectionFactory cf = new DriverConnectionFactory(jdbcDriver, jdbcUri, cfProps); // wrap it with a LocalXAConnectionFactory XAConnectionFactory xacf = new LocalXAConnectionFactory(txMgr, cf); // create the pool object factory PoolableConnectionFactory factory = new PoolableManagedConnectionFactory(xacf, null); factory.setValidationQuery(jdbcElement.getPoolJdbcTestStmt()); factory.setDefaultReadOnly(false); factory.setRollbackOnReturn(false); factory.setEnableAutoCommitOnReturn(false); String transIso = jdbcElement.getIsolationLevel(); if (!transIso.isEmpty()) { if ("Serializable".equals(transIso)) { factory.setDefaultTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); } else if ("RepeatableRead".equals(transIso)) { factory.setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); } else if ("ReadUncommitted".equals(transIso)) { factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); } else if ("ReadCommitted".equals(transIso)) { factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); } else if ("None".equals(transIso)) { factory.setDefaultTransactionIsolation(Connection.TRANSACTION_NONE); } } // configure the pool settings GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setMaxTotal(maxSize); // settings for idle connections poolConfig.setMaxIdle(maxIdle); poolConfig.setMinIdle(minSize); poolConfig.setTimeBetweenEvictionRunsMillis(jdbcElement.getTimeBetweenEvictionRunsMillis()); poolConfig.setMinEvictableIdleTimeMillis(-1); // disabled in favour of setSoftMinEvictableIdleTimeMillis(...) poolConfig.setSoftMinEvictableIdleTimeMillis(jdbcElement.getSoftMinEvictableIdleTimeMillis()); poolConfig.setNumTestsPerEvictionRun(maxSize); // test all the idle connections // settings for when the pool is exhausted poolConfig.setBlockWhenExhausted(true); // the thread requesting the connection waits if no connection is available poolConfig.setMaxWaitMillis(jdbcElement.getPoolSleeptime()); // throw an exception if, after getPoolSleeptime() ms, no connection is available for the requesting thread // settings for the execution of the validation query poolConfig.setTestOnCreate(jdbcElement.getTestOnCreate()); poolConfig.setTestOnBorrow(jdbcElement.getTestOnBorrow()); poolConfig.setTestOnReturn(jdbcElement.getTestOnReturn()); poolConfig.setTestWhileIdle(jdbcElement.getTestWhileIdle()); GenericObjectPool<PoolableConnection> pool = new GenericObjectPool<PoolableConnection>(factory, poolConfig); factory.setPool(pool); mds = new DebugManagedDataSource(pool, xacf.getTransactionRegistry()); mds.setAccessToUnderlyingConnectionAllowed(true); // cache the pool dsCache.putIfAbsent(cacheKey, mds); mds = dsCache.get(cacheKey); return TransactionUtil.getCursorConnection(helperInfo, mds.getConnection()); }
From source file:org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.java
/** * Constructor.//ww w .ja v a2s . c o m * * @param derivations whether to apply product derivations * @param loadGlobals whether to attempt to load the global properties */ public JDBCConfigurationImpl(boolean derivations, boolean loadGlobals) { super(false, false); String[] aliases; schema = addString("jdbc.Schema"); schemas = addStringList("jdbc.Schemas"); transactionIsolation = addInt("jdbc.TransactionIsolation"); aliases = new String[] { "default", String.valueOf(-1), "none", String.valueOf(Connection.TRANSACTION_NONE), "read-committed", String.valueOf(Connection.TRANSACTION_READ_COMMITTED), "read-uncommitted", String.valueOf(Connection.TRANSACTION_READ_UNCOMMITTED), "repeatable-read", String.valueOf(Connection.TRANSACTION_REPEATABLE_READ), "serializable", String.valueOf(Connection.TRANSACTION_SERIALIZABLE) }; transactionIsolation.setAliases(aliases); transactionIsolation.setDefault(aliases[0]); transactionIsolation.set(-1); transactionIsolation.setAliasListComprehensive(true); resultSetType = addInt("jdbc.ResultSetType"); aliases = new String[] { "forward-only", String.valueOf(ResultSet.TYPE_FORWARD_ONLY), "scroll-sensitive", String.valueOf(ResultSet.TYPE_SCROLL_SENSITIVE), "scroll-insensitive", String.valueOf(ResultSet.TYPE_SCROLL_INSENSITIVE), }; resultSetType.setAliases(aliases); resultSetType.setDefault(aliases[0]); resultSetType.set(ResultSet.TYPE_FORWARD_ONLY); resultSetType.setAliasListComprehensive(true); fetchDirection = addInt("jdbc.FetchDirection"); aliases = new String[] { "forward", String.valueOf(ResultSet.FETCH_FORWARD), "reverse", String.valueOf(ResultSet.FETCH_REVERSE), "unknown", String.valueOf(ResultSet.FETCH_UNKNOWN), }; fetchDirection.setAliases(aliases); fetchDirection.setDefault(aliases[0]); fetchDirection.set(ResultSet.FETCH_FORWARD); fetchDirection.setAliasListComprehensive(true); eagerFetchMode = new FetchModeValue("jdbc.EagerFetchMode"); eagerFetchMode.setDefault(FetchModeValue.EAGER_PARALLEL); eagerFetchMode.set(EagerFetchModes.EAGER_PARALLEL); addValue(eagerFetchMode); subclassFetchMode = new FetchModeValue("jdbc.SubclassFetchMode"); subclassFetchMode.setDefault(FetchModeValue.EAGER_JOIN); subclassFetchMode.set(EagerFetchModes.EAGER_JOIN); addValue(subclassFetchMode); lrsSize = addInt("jdbc.LRSSize"); aliases = new String[] { "query", String.valueOf(LRSSizes.SIZE_QUERY), "unknown", String.valueOf(LRSSizes.SIZE_UNKNOWN), "last", String.valueOf(LRSSizes.SIZE_LAST), }; lrsSize.setAliases(aliases); lrsSize.setDefault(aliases[0]); lrsSize.set(LRSSizes.SIZE_QUERY); lrsSize.setAliasListComprehensive(true); synchronizeMappings = addString("jdbc.SynchronizeMappings"); aliases = new String[] { "false", null }; synchronizeMappings.setAliases(aliases); synchronizeMappings.setDefault(aliases[0]); jdbcListenerPlugins = addPluginList("jdbc.JDBCListeners"); jdbcListenerPlugins.setInstantiatingGetter("getJDBCListenerInstances"); connectionDecoratorPlugins = addPluginList("jdbc.ConnectionDecorators"); connectionDecoratorPlugins.setInstantiatingGetter("getConnectionDecoratorInstances"); dbdictionaryPlugin = addPlugin("jdbc.DBDictionary", true); aliases = new String[] { "access", "org.apache.openjpa.jdbc.sql.AccessDictionary", "db2", "org.apache.openjpa.jdbc.sql.DB2Dictionary", "derby", "org.apache.openjpa.jdbc.sql.DerbyDictionary", "empress", "org.apache.openjpa.jdbc.sql.EmpressDictionary", "foxpro", "org.apache.openjpa.jdbc.sql.FoxProDictionary", "h2", "org.apache.openjpa.jdbc.sql.H2Dictionary", "hsql", "org.apache.openjpa.jdbc.sql.HSQLDictionary", "informix", "org.apache.openjpa.jdbc.sql.InformixDictionary", "ingres", "org.apache.openjpa.jdbc.sql.IngresDictionary", "jdatastore", "org.apache.openjpa.jdbc.sql.JDataStoreDictionary", "mysql", "org.apache.openjpa.jdbc.sql.MySQLDictionary", "oracle", "org.apache.openjpa.jdbc.sql.OracleDictionary", "pointbase", "org.apache.openjpa.jdbc.sql.PointbaseDictionary", "postgres", "org.apache.openjpa.jdbc.sql.PostgresDictionary", "soliddb", "org.apache.openjpa.jdbc.sql.SolidDBDictionary", "sqlserver", "org.apache.openjpa.jdbc.sql.SQLServerDictionary", "sybase", "org.apache.openjpa.jdbc.sql.SybaseDictionary", "maxdb", MaxDBDictionary.class.getCanonicalName(), }; dbdictionaryPlugin.setAliases(aliases); dbdictionaryPlugin.setInstantiatingGetter("getDBDictionaryInstance"); updateManagerPlugin = addPlugin("jdbc.UpdateManager", true); aliases = new String[] { "default", BatchingConstraintUpdateManager.class.getName(), "operation-order", "org.apache.openjpa.jdbc.kernel.OperationOrderUpdateManager", "constraint", "org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager", "batching-constraint", BatchingConstraintUpdateManager.class.getName(), "batching-operation-order", BatchingOperationOrderUpdateManager.class.getName(), }; updateManagerPlugin.setAliases(aliases); updateManagerPlugin.setDefault(aliases[0]); updateManagerPlugin.setString(aliases[0]); updateManagerPlugin.setInstantiatingGetter("getUpdateManagerInstance"); driverDataSourcePlugin = addPlugin("jdbc.DriverDataSource", false); aliases = new String[] { "auto", "org.apache.openjpa.jdbc.schema.AutoDriverDataSource", "simple", "org.apache.openjpa.jdbc.schema.SimpleDriverDataSource", "dbcp", "org.apache.openjpa.jdbc.schema.DBCPDriverDataSource", }; driverDataSourcePlugin.setAliases(aliases); driverDataSourcePlugin.setDefault(aliases[0]); driverDataSourcePlugin.setString(aliases[0]); schemaFactoryPlugin = addPlugin("jdbc.SchemaFactory", true); aliases = new String[] { "dynamic", "org.apache.openjpa.jdbc.schema.DynamicSchemaFactory", "native", "org.apache.openjpa.jdbc.schema.LazySchemaFactory", "file", "org.apache.openjpa.jdbc.schema.FileSchemaFactory", "table", "org.apache.openjpa.jdbc.schema.TableSchemaFactory", // deprecated alias "db", "org.apache.openjpa.jdbc.schema.TableSchemaFactory", }; schemaFactoryPlugin.setAliases(aliases); schemaFactoryPlugin.setDefault(aliases[0]); schemaFactoryPlugin.setString(aliases[0]); schemaFactoryPlugin.setInstantiatingGetter("getSchemaFactoryInstance"); sqlFactoryPlugin = addPlugin("jdbc.SQLFactory", true); aliases = new String[] { "default", "org.apache.openjpa.jdbc.sql.SQLFactoryImpl", }; sqlFactoryPlugin.setAliases(aliases); sqlFactoryPlugin.setDefault(aliases[0]); sqlFactoryPlugin.setString(aliases[0]); sqlFactoryPlugin.setInstantiatingGetter("getSQLFactoryInstance"); mappingFactoryPlugin = new MappingFactoryValue("jdbc.MappingFactory"); addValue(mappingFactoryPlugin); mappingDefaultsPlugin = addPlugin("jdbc.MappingDefaults", true); aliases = new String[] { "default", "org.apache.openjpa.jdbc.meta.MappingDefaultsImpl", }; mappingDefaultsPlugin.setAliases(aliases); mappingDefaultsPlugin.setDefault(aliases[0]); mappingDefaultsPlugin.setString(aliases[0]); mappingDefaultsPlugin.setInstantiatingGetter("getMappingDefaultsInstance"); // set up broker factory defaults brokerFactoryPlugin.setAlias("jdbc", JDBCBrokerFactory.class.getName()); brokerFactoryPlugin.setDefault("jdbc"); brokerFactoryPlugin.setString("jdbc"); // set new default for mapping repos metaRepositoryPlugin.setAlias("default", "org.apache.openjpa.jdbc.meta.MappingRepository"); metaRepositoryPlugin.setDefault("default"); metaRepositoryPlugin.setString("default"); // set new default for lock manager lockManagerPlugin.setAlias("pessimistic", PessimisticLockManager.class.getName()); lockManagerPlugin.setDefault("pessimistic"); lockManagerPlugin.setString("pessimistic"); // native savepoint manager options savepointManagerPlugin.setAlias("jdbc", "org.apache.openjpa.jdbc.kernel.JDBC3SavepointManager"); // set new aliases and defaults for sequence seqPlugin.setAliases(JDBCSeqValue.ALIASES); seqPlugin.setDefault(JDBCSeqValue.ALIASES[0]); seqPlugin.setString(JDBCSeqValue.ALIASES[0]); // This plug-in is declared in superclass but defined here // because PreparedQueryCache is currently available for JDBC // backend only preparedQueryCachePlugin = addPlugin("jdbc.QuerySQLCache", true); aliases = new String[] { "true", "org.apache.openjpa.jdbc.kernel.PreparedQueryCacheImpl", "false", null }; preparedQueryCachePlugin.setAliases(aliases); preparedQueryCachePlugin.setAliasListComprehensive(true); preparedQueryCachePlugin.setDefault(aliases[0]); preparedQueryCachePlugin.setClassName(aliases[1]); preparedQueryCachePlugin.setDynamic(true); preparedQueryCachePlugin.setInstantiatingGetter("getQuerySQLCacheInstance"); finderCachePlugin = addPlugin("jdbc.FinderCache", true); aliases = new String[] { "true", "org.apache.openjpa.jdbc.kernel.FinderCacheImpl", "false", null }; finderCachePlugin.setAliases(aliases); finderCachePlugin.setAliasListComprehensive(true); finderCachePlugin.setDefault(aliases[0]); finderCachePlugin.setClassName(aliases[1]); finderCachePlugin.setDynamic(true); finderCachePlugin.setInstantiatingGetter("getFinderCacheInstance"); identifierUtilPlugin = addPlugin("jdbc.IdentifierUtil", true); aliases = new String[] { "default", "org.apache.openjpa.jdbc.identifier.DBIdentifierUtilImpl" }; identifierUtilPlugin.setAliases(aliases); identifierUtilPlugin.setDefault(aliases[0]); identifierUtilPlugin.setString(aliases[0]); identifierUtilPlugin.setInstantiatingGetter("getIdentifierUtilInstance"); // this static initializer is to get past a weird // ClassCircularityError that happens only under IBM's // JDK 1.3.1 on Linux from within the JRun ClassLoader; // while exact causes are unknown, it is almost certainly // a bug in JRun, and we can get around it by forcing // Instruction.class to be loaded and initialized // before TypedInstruction.class try { serp.bytecode.lowlevel.Entry.class.getName(); } catch (Throwable t) { } try { serp.bytecode.Instruction.class.getName(); } catch (Throwable t) { } supportedOptions().add(OPTION_QUERY_SQL); supportedOptions().add(OPTION_JDBC_CONNECTION); supportedOptions().remove(OPTION_VALUE_INCREMENT); supportedOptions().remove(OPTION_NULL_CONTAINER); if (derivations) ProductDerivations.beforeConfigurationLoad(this); if (loadGlobals) loadGlobals(); }
From source file:org.apache.openjpa.jdbc.kernel.JDBCFetchConfigurationImpl.java
public JDBCFetchConfiguration setIsolation(int level) { if (level != -1 && level != DEFAULT && level != Connection.TRANSACTION_NONE && level != Connection.TRANSACTION_READ_UNCOMMITTED && level != Connection.TRANSACTION_READ_COMMITTED && level != Connection.TRANSACTION_REPEATABLE_READ && level != Connection.TRANSACTION_SERIALIZABLE) throw new IllegalArgumentException(_loc.get("bad-level", Integer.valueOf(level)).getMessage()); if (level == DEFAULT) _state.isolationLevel = -1;/*w w w. ja v a2s . co m*/ else _state.isolationLevel = level; return this; }
From source file:org.apache.sandesha2.storage.jdbc.JDBCTransaction.java
public JDBCTransaction(PersistentStorageManager pmgr) { log.debug("new JDBCTransaction"); try {// w ww. j a v a2 s . com this.pmgr = pmgr; dbConnection = pmgr.dbConnect(); dbConnection.setAutoCommit(false); dbConnection.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); active = true; } catch (Exception ex) { } }
From source file:org.apache.slide.store.impl.rdbms.JDBCStore.java
protected static String isolationLevelToString(int isolationLevel) { String levelString;//from w w w .j ava 2 s . co m switch (isolationLevel) { case Connection.TRANSACTION_NONE: levelString = TRANSACTION_NONE; break; case Connection.TRANSACTION_READ_UNCOMMITTED: levelString = TRANSACTION_READ_UNCOMMITTED; break; case Connection.TRANSACTION_READ_COMMITTED: levelString = TRANSACTION_READ_COMMITTED; break; case Connection.TRANSACTION_REPEATABLE_READ: levelString = TRANSACTION_REPEATABLE_READ; break; case Connection.TRANSACTION_SERIALIZABLE: levelString = TRANSACTION_SERIALIZABLE; break; default: levelString = "UNKNOWN"; break; } return levelString; }
From source file:org.apache.slide.store.impl.rdbms.JDBCStore.java
protected static int stringToIsolationLevelToString(String levelString) { if (TRANSACTION_NONE.equals(levelString)) { return Connection.TRANSACTION_NONE; } else if (TRANSACTION_READ_UNCOMMITTED.equals(levelString)) { return Connection.TRANSACTION_READ_UNCOMMITTED; } else if (TRANSACTION_READ_COMMITTED.equals(levelString)) { return Connection.TRANSACTION_READ_COMMITTED; } else if (TRANSACTION_REPEATABLE_READ.equals(levelString)) { return Connection.TRANSACTION_REPEATABLE_READ; } else if (TRANSACTION_SERIALIZABLE.equals(levelString)) { return Connection.TRANSACTION_SERIALIZABLE; } else {/*from w w w . j av a 2 s . c om*/ return -1; } }