This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.sql.Connection; | |
| import java.sql.SQLException; | |
| import org.apache.tomcat.jdbc.pool.DataSource; | |
| import org.apache.tomcat.jdbc.pool.PoolProperties; | |
| public class DataSourceConfig { | |
| public static final String DATA_SOURCE_CLASS_NAME = "org.postgresql.Driver"; | |
| public static final String DATA_SOURCE_URL = "jdbc:postgresql://%s:%s/%s"; | |
| public static final String JDBC_INTERCEPTORS = "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.sql.Connection; | |
| import java.sql.PreparedStatement; | |
| import java.sql.ResultSet; | |
| import java.sql.SQLException; | |
| public class SampleProgram { | |
| public static void main(String[] args) throws SQLException { | |
| DataSourceConfig ds = configureConnection(); | |
| String statement = "SELECT id FROM test_tbl"; | |
| try (Connection con = ds.getConnection()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void insertNames(List<String> names) { | |
| try (Connection connection = config.getConnection()) { | |
| PreparedStatement statement = connection.prepareStatement("INSERT INTO student (name) SELECT * FROM UNNEST(?)"); | |
| statement.setArray(1, connection.createArrayOf("text", names.toArray(new String[names.size()]))); | |
| statement.execute(); | |
| } catch (SQLException e) { | |
| throw new RuntimeException(e); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void insertStudents(List<Student> students) { | |
| String initialInsertStatement = "INSERT INTO student VALUES"; | |
| StringBuilder query = new StringBuilder(initialInsertStatement); | |
| try (Connection connection = config.getConnection()) { | |
| try (Statement statement = connection.createStatement()) { | |
| for (int i = 0; i < students.size(); i++) { | |
| if (i == 0) { | |
| query.append(asSqlQuery(students.get(i))); | |
| } else if (i % 200 != 0) { | |
| query.append(",") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void insertStudents(List<Student> students) { | |
| String statement = "INSERT INTO student VALUES(?,?,?)"; | |
| try (Connection connection = config.getConnection()) { | |
| try (PreparedStatement ps = connection.prepareStatement(statement)) { | |
| for (int i = 0; i < students.size(); i++) { | |
| Student student = students.get(i); | |
| int j = 0; | |
| ps.setString(++j, student.getGuid()); | |
| ps.setString(++j, student.getName()); | |
| ps.setInt(++j, student.getId()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void insertStudents(List<Student> students) { | |
| String statement = "INSERT INTO student VALUES(?,?,?)"; | |
| try (Connection connection = config.getConnection()) { | |
| try (PreparedStatement ps = connection.prepareStatement(statement)) { | |
| for (int i = 0; i < students.size(); i++) { | |
| Student student = students.get(i); | |
| int j = 0; | |
| ps.setString(++j, student.getGuid()); | |
| ps.setString(++j, student.getName()); | |
| ps.setInt(++j, student.getId()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void insertStudents(List<Student> students) { | |
| String statement = "INSERT INTO student VALUES(?,?,?)"; | |
| for (int i = 0; i < students.size(); i++) { | |
| Student student = students.get(i); | |
| try (Connection connection = config.getConnection()) { | |
| try (PreparedStatement ps = connection.prepareStatement(statement)) { | |
| int j = 0; | |
| ps.setString(++j, student.getGuid()); | |
| ps.setString(++j, student.getName()); | |
| ps.setInt(++j, student.getId()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Hello, and welcome to makefile basics. | |
| # | |
| # You will learn why `make` is so great, and why, despite its "weird" syntax, | |
| # it is actually a highly expressive, efficient, and powerful way to build | |
| # programs. | |
| # | |
| # Once you're done here, go to | |
| # http://www.gnu.org/software/make/manual/make.html | |
| # to learn SOOOO much more. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # inspired by https://www.tumfatig.net/20190131/customized-resolution-for-openbsd-in-virtualbox/ | |
| if [ "$(id -u)" -ne 0 ]; then | |
| echo "This script must be run as root" | |
| exit 1 | |
| fi | |
| mkdir -p /etc/X11/xorg.conf.d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| if [ -z "$1" ] || [ -z "$2" ]; then | |
| echo "Pass VBox machine name and screen resolution" | |
| echo "Example: 'OpenBSD New' '1920x1080x32'" | |
| exit 1 | |
| fi | |
| VBoxManage setextradata "$1" CustomVideoMode1 "$2" |
NewerOlder