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
#include<iostream> | |
using namespace std; | |
int main (int args, char *argv[]) { | |
for (int i = 0; i < 5; i++) { | |
for (int j = i; j < 5; j++) { | |
cout << "*"; | |
} | |
for (int j = 0; j <= ((i + 1) * 2); j++) { | |
cout << " "; | |
} |
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
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
<dependency> | |
<groupId>org.apache.tomcat</groupId> | |
<artifactId>tomcat-jdbc</artifactId> | |
<version>8.0.30</version> | |
</dependency> |
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(?,?,?)"; | |
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
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 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
#! /bin/sh | |
""":" | |
exec python $0 ${1+"$@"} | |
""" | |
# This file is part of indicator-weather. | |
# Indicator Weather is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License version 3 | |
# as published by the Free Software Foundation. |
NewerOlder