Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- public class DemoDB {
- public static void main(String[] args) {
- try{
- Class.forName("org.postgresql.Driver");
- Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres","postgres","1234567890");
- PreparedStatement stmt = con.prepareStatement("select kolor from auta");
- ResultSet Rs = stmt.executeQuery();
- while (Rs.next()) {
- System.out.println(Rs.getInt(1)+" "+Rs.getString(2));
- }
- } catch(Exception ex){
- System.out.println(ex.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement