List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate
public NamedParameterJdbcTemplate(JdbcOperations classicJdbcTemplate)
From source file:org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupMembershipManager.java
@Override public int delete(String filter) { SearchQueryConverter.ProcessedFilter where = getQueryConverter().convert(filter, null, false); logger.debug("Filtering groups with SQL: " + where); try {/*from w w w .j a v a2 s .com*/ String completeSql = "DELETE FROM " + getTableName() + " WHERE group_id IN (SELECT id FROM groups WHERE identity_zone_id='" + IdentityZoneHolder.get().getId() + "') AND " + where.getSql(); logger.debug("delete sql: " + completeSql + ", params: " + where.getParams()); return new NamedParameterJdbcTemplate(jdbcTemplate).update(completeSql, where.getParams()); } catch (DataAccessException e) { logger.debug("Filter '" + filter + "' generated invalid SQL", e); throw new IllegalArgumentException("Invalid delete filter: " + filter); } }
From source file:org.cloudfoundry.identity.uaa.zone.MultitenantJdbcClientDetailsService.java
public MultitenantJdbcClientDetailsService(DataSource dataSource) { Assert.notNull(dataSource, "DataSource required"); this.jdbcTemplate = new JdbcTemplate(dataSource); this.listFactory = new DefaultJdbcListFactory(new NamedParameterJdbcTemplate(jdbcTemplate)); }
From source file:org.fao.geonet.arcgis.ArcSDEJdbcConnection.java
/** * * * @param connectionString An example of server string in case of Oracle * is: "jdbc:oracle:thin:@84.123.79.19:1521:orcl". * @param username the username to connect to the database. * @param password the password to connect to the database. *//* w w w. ja va 2 s . co m*/ public ArcSDEJdbcConnection(String driverName, String connectionString, String username, String password) { try { Log.debug(ARCSDE_LOG_MODULE_NAME, "Getting ArcSDE connection (via JDBC)"); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(driverName); dataSource.setUrl(connectionString); dataSource.setUsername(username); dataSource.setPassword(password); // Test the connection config getting a connection and closing it. dataSource.getConnection().close(); jdbcTemplate = new NamedParameterJdbcTemplate(dataSource); } catch (SQLException x) { Log.error(ARCSDE_LOG_MODULE_NAME, "Error getting ArcSDE connection (via JDBC)", x); throw new ExceptionInInitializerError(new ArcSDEConnectionException( "Exception in ArcSDEConnection using JDBC: can not connect to the database", x)); } }
From source file:org.geoserver.jdbcconfig.internal.ConfigDatabase.java
public ConfigDatabase(final DataSource dataSource, final XStreamInfoSerialBinding binding, CacheProvider cacheProvider) {//from w w w. j ava2s. c om this.binding = binding; this.template = new NamedParameterJdbcTemplate(dataSource); // cannot use dataSource at this point due to spring context config hack // in place to support tx during testing this.dataSource = dataSource; this.catalogRowMapper = new InfoRowMapper<CatalogInfo>(CatalogInfo.class, binding); this.configRowMapper = new InfoRowMapper<Info>(Info.class, binding); if (cacheProvider == null) { cacheProvider = DefaultCacheProvider.findProvider(); } cache = cacheProvider.getCache("catalog"); }
From source file:org.geoserver.jdbcconfig.internal.JdbcConfigTestSupport.java
private void runScript(String dbScriptName) throws IOException { NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource); String[] initScript = readDbScript(dbScriptName); JdbcOperations jdbcOperations = template.getJdbcOperations(); for (String sentence : initScript) { try {/*from w w w . j a va 2s . c o m*/ jdbcOperations.update(sentence); } catch (DataAccessException e) { // e.printStackTrace(); throw e; } } }
From source file:org.geoserver.jdbcconfig.JDBCConfigTestSupport.java
private void runScript(String dbScriptName) throws IOException { NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource); URL url = JDBCGeoServerLoader.class.getResource(dbScriptName); if (url == null) { throw new IllegalArgumentException("Script not found: " + getClass().getName() + "/" + dbScriptName); }/*from ww w. ja v a 2 s . c o m*/ Util.runScript(url, template.getJdbcOperations(), null); }
From source file:org.geoserver.jdbcstore.internal.JDBCQueryHelper.java
protected void runScript(Resource script) { NamedParameterJdbcOperations template = new NamedParameterJdbcTemplate(ds); try (InputStream in = script.in()) { Util.runScript(in, template.getJdbcOperations(), null); } catch (IOException ex) { throw new IllegalArgumentException("Could not execute provided sql script", ex); }/*from www . jav a2 s . c o m*/ }
From source file:org.jasig.portlet.notice.service.jdbc.AbstractJdbcNotificationService.java
@PostConstruct public void init() { final String name = getName(); if (StringUtils.isBlank(name)) { throw new IllegalStateException("Notification service name not specified"); }/*from w ww . j av a2s . c o m*/ logger.debug("Initializing AbstractJdbcNotificationService where name={}", name); jdbcTemplate = new NamedParameterJdbcTemplate(dataSource); }
From source file:org.jumpmind.metl.core.runtime.component.AbstractRdbmsComponentRuntime.java
protected NamedParameterJdbcTemplate getJdbcTemplate() { if (dataSource == null && getResourceRuntime() == null) { throw new RuntimeException("The data source resource has not been configured. Please configure it."); }//from ww w . j a v a 2s.c o m if (dataSource == null) { dataSource = (DataSource) getResourceRuntime().reference(); } return new NamedParameterJdbcTemplate(dataSource); }
From source file:org.loyaltyrex.repository.pg.impl.PgBusinessRepository.java
@Inject public PgBusinessRepository(BasicDataSource dataSource) { jdbcTemplate = new NamedParameterJdbcTemplate(dataSource); }