1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| import java.sql.*;
public class TestBD {
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/BDTest","root","30071986");
Statement state = connexion.createStatement();
ResultSet result = state.executeQuery("SELECT * FROM Student");
while(result.next())
System.out.println(result.getInt(1)+" "+result.getString(2)+" "+result.getInt(3)+" ");
connexion.close();
} catch (Exception e) { System.out.println(e);}
}
} |
Partager