Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * BDA
- * TP JDBC
- *
- * Appel d'une procedure stockee permettant de verifier, pour un numero de client (numClient) si le client est en retard pour rendre un dvd.
- * Remarque : retour de 0/1 par un parametre out.
- *
- * @author Toto
- * @version 1.0
- */
- public class TD1_8_VerificationRetard {
- public static void main(String[] args) {
- Connection conn = null;
- PreparedStatement stmt = null;
- ResultSet rs = null;
- String numclient = null;
- if(args.length < 1) {
- System.out.println("usage: java Exo8VerificationRetard NumClient\nArguments: numero du client (idClient)");
- System.exit(0);
- }
- numclient = args[0];
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- }
- catch (ClassNotFoundException e) {
- System.err.println("Erreur lors du chargement du pilote : " + e.getMessage());
- e.printStackTrace();
- }
- try {
- conn = DriverManager.getConnection("jdbc:oracle:thin:@pedaserv1.luminy.univmed.fr:1521","compte99","compte99");
- CallableStatement csmt = conn.prepareCall("{ call est_retardataire(?, ?) }");
- csmt.registerOutParameter(2, Types.SMALLINT);
- csmt.setString(1, numclient);
- csmt.execute();
- int cout = csmt.getInt(2);
- if(cout == 1) System.out.println("Client retardataire !");
- else System.out.println("Client OK");
- }
- catch(SQLException e2) {
- System.err.println("Erreur : " + e2.getMessage());
- e2.printStackTrace();
- }
- finally {
- try {
- if(rs != null) rs.close();
- if(stmt != null) stmt.close();
- if(conn != null) conn.close();
- }
- catch(SQLException e3) {
- System.err.println("Erreur lors de la fermeture des ressources : "
- + e3.getMessage());
- e3.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement