import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import java.sql.SQLException; import java.sql.ResultSet; import java.util.Properties; public class App { public static void main(String[] args) throws Exception { String url = "jdbc:postgresql://localhost/zoldzrt"; Properties props = new Properties(); props.setProperty("user", "zoldzrt"); props.setProperty("password", "titok"); props.setProperty("ssl", "ture"); try { Connection conn = DriverManager.getConnection(url, props); System.out.println("Ok. A kapcsolódás sikeres."); String sql = "select * from employees"; Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(sql); while(rs.next()) { System.out.printf( "%d %15s %8s %.1f %s\n", rs.getInt("id"), rs.getString("name"), rs.getString("city"), rs.getDouble("salary"), rs.getDate("birth") ); } } catch (SQLException e) { System.err.println("Hiba!"); System.err.println(e.getMessage()); } } }