42 lines
992 B
Java
42 lines
992 B
Java
import java.sql.*;
|
|
import org.mariadb.jdbc.*;
|
|
|
|
public class MonProgramme {
|
|
|
|
public MonProgramme() {
|
|
try {
|
|
Connection cnx = DriverManager.getConnection("jdbc:mariadb://dwarves.iut-fbleau.fr/srivasta","login", "mdp");
|
|
|
|
PreparedStatement pst = cnx.prepareStatement("SELECT name FROM episode WHERE id BETWEEN ? AND ?");
|
|
pst.setInt(1, 50);
|
|
pst.setInt(2, 100);
|
|
ResultSet rs = pst.executeQuery();
|
|
|
|
while(rs.next()) {
|
|
String name = rs.getString("name");
|
|
System.out.println("Episode: " + name);
|
|
}
|
|
|
|
// Fermeture des ressources
|
|
rs.close();
|
|
pst.close();
|
|
cnx.close();
|
|
|
|
|
|
}catch(SQLException e) {
|
|
System.err.println("Connexion echouee : "+e);
|
|
}
|
|
|
|
try {
|
|
Class.forName("org.mariadb.jdbc.Driver");
|
|
} catch(ClassNotFoundException e) {
|
|
System.err.println("Classe non trouvee : "+e);
|
|
}
|
|
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
MonProgramme monpgr = new MonProgramme();
|
|
}
|
|
|
|
} |