List of usage examples for java.sql Connection TRANSACTION_NONE
int TRANSACTION_NONE
To view the source code for java.sql Connection TRANSACTION_NONE.
Click Source Link
From source file:Main.java
public static void main(String[] args) throws Exception { int tx = conn.getMetaData().getDefaultTransactionIsolation(); String txtxt = null;/*from w ww. j ava2 s . com*/ switch (tx) { case Connection.TRANSACTION_NONE: txtxt = "TRANSACTION_NONE"; break; case Connection.TRANSACTION_READ_COMMITTED: txtxt = "TRANSACTION_READ_COMMITTED"; break; case Connection.TRANSACTION_READ_UNCOMMITTED: txtxt = "TRANSACTION_READ_UNCOMMITTED"; break; case Connection.TRANSACTION_REPEATABLE_READ: txtxt = "TRANSACTION_REPEATABLE_READ"; break; case Connection.TRANSACTION_SERIALIZABLE: txtxt = "TRANSACTION_SERIALIZABLE"; break; default: txtxt = "UNKNOWN!!"; } System.out.println(txtxt); conn.setTransactionIsolation(tx); System.out.println("Done"); conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); System.out.println("TX is now " + conn.getTransactionIsolation()); }
From source file:TXInfo.java
public static void main(String[] a) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:MusicVideo"); int tx = con.getMetaData().getDefaultTransactionIsolation(); String txtxt = null;//from w w w . ja v a 2s .c o m switch (tx) { case Connection.TRANSACTION_NONE: txtxt = "TRANSACTION_NONE"; break; case Connection.TRANSACTION_READ_COMMITTED: txtxt = "TRANSACTION_READ_COMMITTED"; break; case Connection.TRANSACTION_READ_UNCOMMITTED: txtxt = "TRANSACTION_READ_UNCOMMITTED"; break; case Connection.TRANSACTION_REPEATABLE_READ: txtxt = "TRANSACTION_REPEATABLE_READ"; break; case Connection.TRANSACTION_SERIALIZABLE: txtxt = "TRANSACTION_SERIALIZABLE"; break; default: txtxt = "UNKNOWN!!"; } System.out.println(txtxt); con.setTransactionIsolation(tx); System.out.println("Done"); con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); System.out.println("TX is now " + con.getTransactionIsolation()); }
From source file:org.apache.slide.store.impl.rdbms.JDBCStore.java
protected static String isolationLevelToString(int isolationLevel) { String levelString;//from www . ja v a 2s .c om 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:JDBCMeta.java
/** * Convert a TransactionIsolation int (defined in java.sql.Connection) to * the corresponding printable string.//from w w w .j a v a2 s . co m */ public static String transactionIsolationToString(int txisolation) { switch (txisolation) { case Connection.TRANSACTION_NONE: // transactions not supported. return "TRANSACTION_NONE"; case Connection.TRANSACTION_READ_UNCOMMITTED: // All three phenomena can occur return "TRANSACTION_NONE"; case Connection.TRANSACTION_READ_COMMITTED: // Dirty reads are prevented; non-repeatable reads and // phantom reads can occur. return "TRANSACTION_READ_COMMITTED"; case Connection.TRANSACTION_REPEATABLE_READ: // Dirty reads and non-repeatable reads are prevented; // phantom reads can occur. return "TRANSACTION_REPEATABLE_READ"; case Connection.TRANSACTION_SERIALIZABLE: // All three phenomena prvented; slowest! return "TRANSACTION_SERIALIZABLE"; default: throw new IllegalArgumentException(txisolation + " not a valid TX_ISOLATION"); } }
From source file:org.apache.jena.jdbc.remote.statements.RemoteEndpointStatement.java
/** * Creates a new statement//www . j a v a 2 s. c o m * * @param connection * Connection * @param type * Result Set type for result sets produced by this statement * @param client * HTTP client * @param fetchDir * Fetch Direction * @param fetchSize * Fetch Size * @param holdability * Result Set holdability * @throws SQLException * Thrown if there is an error with the statement parameters * */ public RemoteEndpointStatement(RemoteEndpointConnection connection, HttpClient client, int type, int fetchDir, int fetchSize, int holdability) throws SQLException { super(connection, type, fetchDir, fetchSize, holdability, false, Connection.TRANSACTION_NONE); this.remoteConn = connection; this.client = client; }
From source file:fr.xebia.management.config.ManagedBasicDataSourceBeanDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ManagedBasicDataSource.class); builder.setRole(BeanDefinition.ROLE_APPLICATION); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); fillBuilderWithAttributeIfExists(builder, element, "accessToUnderlyingConnectionAllowed", "access-to-underlying-connection-allowed", boolean.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "connectionInitSqls", "connection-init-sqls", java.util.Collection.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "connectionProperties", "connection-properties", String.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "defaultAutoCommit", "default-auto-commit", boolean.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "defaultCatalog", "default-catalog", String.class, parserContext);//from w ww .j a va2 s . c o m fillBuilderWithAttributeIfExists(builder, element, "defaultReadOnly", "default-read-only", boolean.class, parserContext); Element defaultTransactionIsolationElement = DomUtils.getChildElementByTagName(element, "default-transaction-isolation"); if (defaultTransactionIsolationElement != null) { int defaultTransactionIsolation; String value = defaultTransactionIsolationElement.getAttribute("value"); if ("NONE".equals(value)) { defaultTransactionIsolation = Connection.TRANSACTION_NONE; } else if ("READ_UNCOMMITTED".equals(value)) { defaultTransactionIsolation = Connection.TRANSACTION_READ_UNCOMMITTED; } else if ("READ_COMMITTED".equals(value)) { defaultTransactionIsolation = Connection.TRANSACTION_READ_COMMITTED; } else if ("REPEATABLE_READ".equals(value)) { defaultTransactionIsolation = Connection.TRANSACTION_REPEATABLE_READ; } else if ("SERIALIZABLE".equals(value)) { defaultTransactionIsolation = Connection.TRANSACTION_SERIALIZABLE; } else { String msg = "Invalid value for '<default-transaction-isolation' value=\"" + value + "\" />'"; parserContext.getReaderContext().fatal(msg, defaultTransactionIsolationElement); throw new IllegalStateException(msg); } builder.addPropertyValue("defaultTransactionIsolation", defaultTransactionIsolation); } fillBuilderWithAttributeIfExists(builder, element, "driverClassName", "driver-class-name", String.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "initialSize", "initial-size", int.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "logAbandoned", "log-abandoned", boolean.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "maxActive", "max-active", int.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "maxIdle", "max-idle", int.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "maxOpenPreparedStatements", "max-open-prepared-statements", int.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "maxWait", "max-wait", long.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "minEvictableIdleTimeMillis", "min-evictable-idle-time-millis", long.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "minIdle", "min-idle", int.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "numTestsPerEvictionRun", "num-tests-per-eviction-run", int.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "password", "password", String.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "poolPreparedStatements", "pool-prepared-statements", boolean.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "removeAbandoned", "remove-abandoned", boolean.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "removeAbandonedTimeout", "remove-abandoned-timeout", int.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "testOnBorrow", "test-on-borrow", boolean.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "testOnReturn", "test-on-return", boolean.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "testWhileIdle", "test-while-idle", boolean.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "timeBetweenEvictionRunsMillis", "time-between-eviction-runs-millis", long.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "url", "url", String.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "username", "username", String.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "validationQuery", "validation-query", String.class, parserContext); fillBuilderWithAttributeIfExists(builder, element, "validationQueryTimeout", "validation-query-timeout", int.class, parserContext); builder.setDestroyMethodName("close"); return builder.getBeanDefinition(); }
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 ww w. jav a2s. c om return -1; } }
From source file:org.apache.jena.jdbc.remote.statements.RemoteEndpointPreparedStatement.java
/** * Creates a new statement//w w w . ja va2 s . c o m * * @param sparql * SPARQL command * @param connection * Connection * @param client * HTTP client * @param type * Result Set type for result sets produced by this statement * @param fetchDir * Fetch Direction * @param fetchSize * Fetch Size * @param holdability * Result Set holdability * @throws SQLException * Thrown if there is an error with the statement parameters * */ public RemoteEndpointPreparedStatement(String sparql, RemoteEndpointConnection connection, HttpClient client, int type, int fetchDir, int fetchSize, int holdability) throws SQLException { super(sparql, connection, type, fetchDir, fetchSize, holdability, false, Connection.TRANSACTION_NONE); this.remoteConn = connection; this.client = client; }
From source file:org.sakaiproject.tomcat.jdbc.pool.SakaiBasicDataSource.java
/** * Set the default transaction isolation level from a string value, based on the settings and values in java.sql.Connection * /* www.jav a 2 s . c o m*/ * @param defaultTransactionIsolation */ public void setDefaultTransactionIsolationString(String defaultTransactionIsolation) { if ((defaultTransactionIsolation == null) || (defaultTransactionIsolation.trim().length() == 0)) { setDefaultTransactionIsolation(DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION); } else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_NONE")) { setDefaultTransactionIsolation(Connection.TRANSACTION_NONE); } else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_READ_UNCOMMITTED")) { setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); } else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_READ_COMMITTED")) { setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); } else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_REPEATABLE_READ")) { setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); } else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_SERIALIZABLE")) { setDefaultTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); } else { setDefaultTransactionIsolation(DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION); M_log.warn("invalid transaction isolation level: " + defaultTransactionIsolation); } }
From source file:com.amazon.carbonado.repo.jdbc.JDBCRepository.java
static IsolationLevel mapIsolationLevelFromJdbc(int jdbcLevel) { switch (jdbcLevel) { case Connection.TRANSACTION_NONE: default:// w w w.j av a2 s . c o m return IsolationLevel.NONE; case Connection.TRANSACTION_READ_UNCOMMITTED: return IsolationLevel.READ_UNCOMMITTED; case Connection.TRANSACTION_READ_COMMITTED: return IsolationLevel.READ_COMMITTED; case Connection.TRANSACTION_REPEATABLE_READ: return IsolationLevel.REPEATABLE_READ; case Connection.TRANSACTION_SERIALIZABLE: return IsolationLevel.SERIALIZABLE; } }