List of usage examples for org.springframework.jdbc.datasource SingleConnectionDataSource setAutoCommit
public void setAutoCommit(boolean autoCommit)
From source file:ru.adios.budgeter.BundleProvider.java
private static SingleConnectionDataSource createDataSource(String url) { final SingleConnectionDataSource dataSource = new SingleConnectionDataSource(url, true) { @Override/* w ww. j a va 2s . co m*/ protected Connection getCloseSuppressingConnectionProxy(Connection target) { return new DelegatingConnectionProxy(target); } }; dataSource.setAutoCommit(true); dataSource.setDriverClassName("org.sqldroid.SQLDroidDriver"); try { dataSource.initConnection(); } catch (SQLException ex) { throw new DataAccessResourceFailureException("Unable to initialize SingleConnectionDataSource", ex); } return dataSource; }
From source file:org.osgp.adapter.protocol.dlms.application.config.DlmsPersistenceConfig.java
/** * Method for creating the Data Source.//from w ww. ja va 2 s. c o m * * @return DataSource */ public DataSource dlmsDataSource() { final SingleConnectionDataSource singleConnectionDataSource = new SingleConnectionDataSource(); singleConnectionDataSource.setAutoCommit(false); final Properties properties = new Properties(); properties.setProperty("socketTimeout", "0"); properties.setProperty("tcpKeepAlive", "true"); singleConnectionDataSource .setDriverClassName(this.environment.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER)); singleConnectionDataSource.setUrl(this.environment.getRequiredProperty(PROPERTY_NAME_DATABASE_URL)); singleConnectionDataSource .setUsername(this.environment.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME)); singleConnectionDataSource .setPassword(this.environment.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD)); singleConnectionDataSource.setSuppressClose(true); return singleConnectionDataSource; }
From source file:com.github.ferstl.spring.jdbc.oracle.dsconfig.SingleConnectionDataSourceConfiguration.java
@Bean public DataSource dataSource() throws SQLException { SingleConnectionDataSource ds = new SingleConnectionDataSource(this.env.getProperty("db.url"), this.env.getProperty("db.username"), this.env.getProperty("db.password"), this.env.getProperty("db.defaultAutoCommit", Boolean.class)); ds.setAutoCommit(false); return ds;//from w w w. j a va 2s.c om }
From source file:gov.nih.nci.cabig.ctms.tools.configuration.DatabaseBackedConfigurationTest.java
@Override protected void setUp() throws Exception { super.setUp(); sessionFactory = new AnnotationConfiguration().addAnnotatedClass(DefaultConfigurationEntry.class) .addAnnotatedClass(AlternateConfigurationEntry.class) .setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver") .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test" + Math.random()) .setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "") .buildSessionFactory();/*from w w w . j av a 2s . c o m*/ stubListener = new StubConfigurationListener(); configuration = new ExampleConfiguration(); configuration.setSessionFactory(sessionFactory); configuration.addConfigurationListener(stubListener); altConfiguration = new AlternateConfiguration(); altConfiguration.setSessionFactory(sessionFactory); SingleConnectionDataSource ds = new SingleConnectionDataSource(sessionFactory.openSession().connection(), false); ds.setAutoCommit(true); jdbc = new JdbcTemplate(ds); for (String table : new String[] { DEFAULT_TABLE, ALT_TABLE }) { jdbc.execute(String.format( "CREATE TABLE %s (key VARCHAR(255) PRIMARY KEY, value VARCHAR(255), version INTEGER DEFAULT '0' NOT NULL)", table)); } }