1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <%
String url = "jdbc:mysql://localhost/mabase?user=root";
Connection connection;
connection = DriverManager.getConnection(url);
Statement statement = connection.createStatement(
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
String sql = "SELECT * FROM MaTable";
ResultSet resultat = statement.executeQuery(sql);
while(resultat.next()){
int id = resultat.getInt("id");
String nom = resultat.getString("nom");
double prix = resultat.getDouble("prix");
java.sql.Date date = resultat.getDate("date");
int row = resultat.getRow();
System.out.println("Données contenues dans la ligne "+row);
System.out.println("id : "+id+" nom : "+nom+
" prix : "+prix+" date : "+date);
}
resultat.close();
statement.close();
connection.close();
%> |
Partager