String url = "jdbc:postgresql://localhost:5432/mydatabase";
String username = "myusername";
String password = "mypassword";
Connection connection = DriverManager.getConnection(url, username, password);
Statement statement = connection.createStatement();
String sql = "SELECT * FROM mytable";
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
}
resultSet.close();
statement.close();
connection.setAutoCommit(false);
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:5432/mydatabase";
String username = "myusername";
String password = "mypassword";
Connection connection = DriverManager.getConnection(url, username, password);