/** * Set the query timeout for statements that this RDBMS operation executes. * <p>Default is 0, indicating to use the JDBC driver's default. * <p>Note: Any timeout specified here will be overridden by the remaining * transaction timeout when executing within a transaction that has a * timeout specified at the transaction level. */ public void setQueryTimeout(int queryTimeout) { this.jdbcTemplate.setQueryTimeout(queryTimeout); }
@Override public boolean checkMasterWritable() { testMasterWritableJT.setDataSource(jt.getDataSource()); /** * 防止login接口因为主库不可用而rt太长 */ testMasterWritableJT.setQueryTimeout(1); String sql = " SELECT @@read_only "; try { Integer result = testMasterWritableJT.queryForObject(sql, Integer.class); if (result == null) { return false; } else { return result.intValue() == 0 ? true : false; } } catch (CannotGetJdbcConnectionException e) { fatalLog.error("[db-error] " + e.toString(), e); return false; } }
jt.setQueryTimeout(queryTimeout); testMasterJT.setQueryTimeout(queryTimeout); testMasterWritableJT.setQueryTimeout(1);
@Override public void run() { defaultLog.info("check master db."); boolean isFound = false; int index = -1; for (BasicDataSource ds : dataSourceList) { index++; testMasterJT.setDataSource(ds); testMasterJT.setQueryTimeout(queryTimeout); try { testMasterJT .update("DELETE FROM config_info WHERE data_id='com.alibaba.nacos.testMasterDB'"); if (jt.getDataSource() != ds) { fatalLog.warn("[master-db] {}", ds.getUrl()); } jt.setDataSource(ds); tm.setDataSource(ds); isFound = true; masterIndex = index; break; } catch (DataAccessException e) { // read only e.printStackTrace(); // TODO remove } } if (!isFound) { fatalLog.error("[master-db] master db not found."); MetricsMonitor.getDbException().increment(); } } }
jdbcTemplate.setQueryTimeout(queryTimeout); jdbcTemplate.setDataSource(ds);
@PostConstruct public void init() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(JDBC_DRIVER_NAME); ds.setUrl("jdbc:derby:" + NACOS_HOME + File.separator + DERBY_BASE_DIR + ";create=true"); ds.setUsername(USER_NAME); ds.setPassword(PASSWORD); ds.setInitialSize(20); ds.setMaxActive(30); ds.setMaxIdle(50); ds.setMaxWait(10000L); ds.setPoolPreparedStatements(true); ds.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES .toMillis(10L)); ds.setTestWhileIdle(true); jt = new JdbcTemplate(); jt.setMaxRows(50000); jt.setQueryTimeout(5000); jt.setDataSource(ds); DataSourceTransactionManager tm = new DataSourceTransactionManager(); tjt = new TransactionTemplate(tm); tm.setDataSource(ds); tjt.setTimeout(5000); if (STANDALONE_MODE && !propertyUtil.isStandaloneUseMysql()) { reload(); } }
template.setQueryTimeout(queryTimeout.intValue());
/** * Set the query timeout for statements that this RDBMS operation executes. * <p>Default is 0, indicating to use the JDBC driver's default. * <p>Note: Any timeout specified here will be overridden by the remaining * transaction timeout when executing within a transaction that has a * timeout specified at the transaction level. */ public void setQueryTimeout(int queryTimeout) { this.jdbcTemplate.setQueryTimeout(queryTimeout); }
/** * Set the query timeout for statements that this RDBMS operation executes. * <p>Default is 0, indicating to use the JDBC driver's default. * <p>Note: Any timeout specified here will be overridden by the remaining * transaction timeout when executing within a transaction that has a * timeout specified at the transaction level. */ public void setQueryTimeout(int queryTimeout) { this.jdbcTemplate.setQueryTimeout(queryTimeout); }
public void setQueryTimeout(int queryTimeout) { delegate.setQueryTimeout(queryTimeout); }
public void setQueryTimeout(int queryTimeout) { delegate.setQueryTimeout(queryTimeout); }
JdbcTemplate template = new JdbcTemplate(...); template.setQueryTimeout(...); NamedParameterJdbcTemplate named = new NamedParameterJdbcTemplate(template);
JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource); jdbcTemplate.setQueryTimeout(2); jdbcTemplate.execute(...);
@Bean public JdbcTemplate clickHouseJdbcTemplate( DataSource clickHouseDataSource, @Value("${graphouse.clickhouse.query-timeout-seconds}") int queryTimeoutSeconds ) { final JdbcTemplate jdbcTemplate = new JdbcTemplate(); jdbcTemplate.setDataSource(clickHouseDataSource); jdbcTemplate.setQueryTimeout(queryTimeoutSeconds); return jdbcTemplate; }
@Bean public JdbcTemplate clickHouseJdbcTemplateAutohide( DataSource clickHouseDataSource, @Value("${graphouse.autohide.clickhouse.query-timeout-seconds}") int autoHideQueryTimeoutSeconds) { final JdbcTemplate jdbcTemplate = new JdbcTemplate(); jdbcTemplate.setDataSource(clickHouseDataSource); jdbcTemplate.setQueryTimeout(autoHideQueryTimeoutSeconds); return jdbcTemplate; }
/** * hive metadata read JDBC template. Query timeout is set to control long running read queries. * * @param connectorContext connector config. * @param hiveDataSource hive data source * @return hive JDBC Template */ @Bean public JdbcTemplate hiveReadJdbcTemplate( final ConnectorContext connectorContext, @Qualifier("hiveDataSource") final DataSource hiveDataSource) { final JdbcTemplate result = new JdbcTemplate(hiveDataSource); result.setQueryTimeout(getDataStoreReadTimeout(connectorContext) / 1000); return result; }
/** * hive metadata write JDBC template. Query timeout is set to control long running write queries. * * @param connectorContext connector config. * @param hiveDataSource hive data source * @return hive JDBC Template */ @Bean public JdbcTemplate hiveWriteJdbcTemplate( final ConnectorContext connectorContext, @Qualifier("hiveDataSource") final DataSource hiveDataSource) { final JdbcTemplate result = new JdbcTemplate(hiveDataSource); result.setQueryTimeout(getDataStoreWriteTimeout(connectorContext) / 1000); return result; }
/** * hive metadata read JDBC template. Query timeout is set to control long running read queries. * * @param connectorContext connector config. * @param hiveDataSource hive data source * @return hive JDBC Template */ @Bean public JdbcTemplate hiveReadJdbcTemplate( final ConnectorContext connectorContext, @Qualifier("hiveDataSource") final DataSource hiveDataSource) { final JdbcTemplate result = new JdbcTemplate(hiveDataSource); result.setQueryTimeout(getDataStoreReadTimeout(connectorContext) / 1000); return result; }
/** * hive metadata write JDBC template. Query timeout is set to control long running write queries. * * @param connectorContext connector config. * @param hiveDataSource hive data source * @return hive JDBC Template */ @Bean public JdbcTemplate hiveWriteJdbcTemplate( final ConnectorContext connectorContext, @Qualifier("hiveDataSource") final DataSource hiveDataSource) { final JdbcTemplate result = new JdbcTemplate(hiveDataSource); result.setQueryTimeout(getDataStoreWriteTimeout(connectorContext) / 1000); return result; }
/** * 创建一个SQL实例 */ public SQL sql() { if (this.jdbcTemplate == null) { this.jdbcTemplate = new JdbcTemplate(); this.jdbcTemplate.setIgnoreWarnings(ignoreWarnings); this.jdbcTemplate.setFetchSize(fetchSize); this.jdbcTemplate.setMaxRows(maxRows); this.jdbcTemplate.setQueryTimeout(queryTimeout); this.jdbcTemplate.setSkipResultsProcessing(skipResultsProcessing); this.jdbcTemplate.setSkipUndeclaredResults(skipUndeclaredResults); this.jdbcTemplate.setResultsMapCaseInsensitive(resultsMapCaseInsensitive); this.jdbcTemplate.setDataSource(this.dataSource); } return new SQL(this.jdbcTemplate, this.dataSourceType); }