Code:
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/amazone_db", "postgres",
"admin");
PreparedStatement stmt = con.prepareStatement("select * from mail.role");
ResultSet Rs = stmt.executeQuery();
while (Rs.next()) {
System.out.println(Rs.getInt(1)+" "+Rs.getString(2));
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
}
Configuration
Demo:
0 comments:
Post a Comment