Skip to content

Instantly share code, notes, and snippets.

@eriklumme
eriklumme / LiquibaseRunner.java
Created June 10, 2020 17:47
Liquibase from Java
public LiquibaseRunner(Properties properties, String changeLogSchema, String updateSchema) {
this.properties = properties;
this.changeLogSchema = changeLogSchema;
this.updateSchema= updateSchema;
}
@eriklumme
eriklumme / LiquibaseRunner.java
Created June 10, 2020 17:54
Liquibase from Java
Connection getConnection() throws SQLException {
return DriverManager.getConnection(
properties.getProperty("url"),
properties.getProperty("username"),
properties.getProperty("password"));
}
@eriklumme
eriklumme / LiquibaseRunner.java
Created June 10, 2020 17:59
Liquibase from Java
private Database getDatabase() throws SQLException, DatabaseException {
Connection connection = getConnection();
connection.prepareStatement(String.format("SET search_path TO '%s'", updateSchema)).execute();
Database database = DatabaseFactory.getInstance()
.findCorrectDatabaseImplementation(new JdbcConnection(connection));
database.setDefaultSchemaName(changeLogSchema);
return database;
}
@eriklumme
eriklumme / LiquibaseRunner.java
Created June 10, 2020 18:10
Liquibase from Java
private Liquibase getLiquibase() throws DatabaseException, SQLException {
return new Liquibase(CHANGELOG_PATH, new ClassLoaderResourceAccessor(), getDatabase());
}
@eriklumme
eriklumme / LiquibaseRunner.java
Created June 10, 2020 18:10
Liquibase from Java
private Liquibase getLiquibase() throws DatabaseException, SQLException {
return new Liquibase(CHANGELOG_PATH, new ClassLoaderResourceAccessor(), getDatabase());
}
@eriklumme
eriklumme / LiquibaseRunner.java
Last active January 3, 2022 13:43
Liquibase from Java
private void doRun() throws Exception {
try (Liquibase liquibase = getLiquibase()) {
liquibase.update(new Contexts(), new LabelExpression());
}
}
@eriklumme
eriklumme / Stock.java
Created October 15, 2020 19:12
Stock Tracker
public class Stock {
private String symbol;
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
@eriklumme
eriklumme / Stock.java
Created October 15, 2020 19:13
Stock Tracker
public class Stock {
private String symbol;
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
@eriklumme
eriklumme / StockService.java
Created October 15, 2020 19:13
Stock Tracker
@Endpoint
@AnonymousAllowed
public class StockService {
private static final Set<Stock> stocks = new HashSet<>();
static {
Stock google = new Stock();
google.setSymbol("GOOGL");
stocks.add(google);
@eriklumme
eriklumme / stock-tracker.ts
Last active October 15, 2020 19:58
Stock Tracker 3
import {LitElement, html, customElement} from 'lit-element';
@customElement("stock-tracker")
export class StockTracker extends LitElement {
render() {
return html`
`;
}
}