package testpg9; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Carlo */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { Connection connection = null; Statement statement = null; ResultSet resultSet = null; String url = "jdbc:postgresql://localhost:5432/postgres"; String driverName = "org.postgresql.Driver"; String user = "postgres"; String password = "*****"; try { Class.forName(driverName); } catch (ClassNotFoundException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } try { connection = DriverManager.getConnection(url, user, password); statement = connection.createStatement(); resultSet = statement.executeQuery("SHOW client_encoding"); if(resultSet.next()) System.out.println("client_encoding = " + resultSet.getString(1)); resultSet = statement.executeQuery("SELECT * FROM clients"); } catch (SQLException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } }