Skip to content

Instantly share code, notes, and snippets.

@javathought
javathought / start_postgres.sh
Created December 12, 2016 21:36
local PostgreSQL cons before Heroku deploy
export DATABASE_URL=jdbc:postgresql://localhost/$(whoami)
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
# /etc/init.d/mysql stop
Shutting down MySQL..
# mysqld_safe --skip-grant-tables --skip-networking &
[1] 4983
# Starting mysqld daemon with databases from /var/lib/mysql
# mysql mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.21-log
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
PreparedStatement preparedStatement = connection.prepareStatement(sql);
for (int i = 0; i < 1000; i++) {
preparedStatement.setObject(1, someValue);
preparedStatement.addBatch();
if ((i + 1) % 100 == 0) {
preparedStatement.executeBatch();
}
}
preparedStatement.executeBatch();
preparedStatement.close();