Skip to content

Instantly share code, notes, and snippets.

@mdellabitta
mdellabitta / gist:1444003
Created December 7, 2011 18:32
how do do spring jdbc transactions with jdbctemplate/transactiontemplate
public class ExodusWriter {
private JdbcTemplate jdbcTemplate;
private TransactionTemplate transactionTemplate;
public ExodusWriter(DataSource dataSource) {
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
jdbcTemplate = new JdbcTemplate(transactionManager.getDataSource());
transactionTemplate = new TransactionTemplate(transactionManager);
}
@troyk
troyk / pg_stat_statements
Created January 5, 2013 18:18
enable postgres pg_stat_statements
1) see re: increasing shmmax http://stackoverflow.com/a/10629164/1283020
2) add to postgresql.conf:
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
136 pg_stat_statements.max = 1000
137 pg_stat_statements.track = all
3) restart postgres
4) check it out in psql
@odrotbohm
odrotbohm / StoreRepository.java
Last active October 22, 2021 09:08
Dynamic, Querydsl-based filter bindings using Spring Data REST
public interface StoreRepository extends PagingAndSortingRepository<Store, String>,
QueryDslPredicateExecutor<Store>, QuerydslBinderCustomizer<QStore> {
@RestResource(rel = "by-location")
Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable);
default void customize(QuerydslBindings bindings, QStore store) {
bindings.bind(store.address.city).single((path, value) -> path.startsWith(value));
bindings.bind(String.class).single((StringPath path, String value) -> path.contains(value));
}
@johanndt
johanndt / upgrade-postgres-9.3-to-9.5.md
Last active July 27, 2024 16:49 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
Connection connection = null;
CallableStatement call = null;
try {
connection = dataSource.getConnection();
call = connection.prepareCall("{? = call get_entity2 (?)}");
call.registerOutParameter(1, Types.VARCHAR);
call.setString(2, tableName);
call.executeUpdate();
return call.getString(1);
} catch (SQLException e) {
@daniellavoie
daniellavoie / logstash-grok-spring-boot.conf
Last active January 29, 2023 08:24
Logstash grok filter for Logback Logger used by Spring Boot applications
input {
file {
path => /tmp/application.log
codec => multiline {
pattern => "^(%{TIMESTAMP_ISO8601})"
negate => true
what => "previous"
}
}
}