1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| package helloword;
import java.sql.*;
public class helloword {
public static void main(String[] args) throws SQLException {
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Le pilote JDBC MySQL a été chargé");
Connection connexion = DriverManager.getConnection("jdbc:mysql://localhost/entrepot","root","");
Statement state = connexion.createStatement();
ResultSet result = state.executeQuery("SELECT * FROM customer");
while(result.next())
System.out.println(result.getInt(1)+" "+result.getString(2)+" "+result.getString(3)+" "+result.getString(4));
connexion.close();
} catch (Exception e) { System.out.println(e);}
}
} |
Partager