1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| import java.sql.*;
public class Test {
public static void main(String[] args) throws Exception
{
// try
// {
Class.forName("org.postgresql.Driver");
Connection c = DriverManager.getConnection("jdbc:postgresql:Essai","postgres","fahmi");
Statement s = c.createStatement();
ResultSet r =
s.executeQuery("SELECT id, nom FROM inscrits");
while (r.next())
System.out.println(r.getInt(1)+"\t"+r.getString(2));
r.close(); s.close(); c.close();
//}
// catch (ClassNotFoundException ex) { System.err.println("Erreur Driver");}
} } |
Partager