
package ejerciciojdbc6;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Types;

public class EjercicioJDBC6 {

    public static void main(String[] args) {
        try {
              //    CONEXION MySQL
              Class.forName("com.mysql.jdbc.Driver");
              Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/biblioteca", "root", "");  
/*              
              //    CONEXION Oracle
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "tiger");  
*/  
              String idLibroBuscado = "00002";
              CallableStatement callableStatement = connection.prepareCall("{CALL consulta_titulo_pro(?,?)}");
              callableStatement.registerOutParameter(2, Types.VARCHAR);  
              callableStatement.setString(1, idLibroBuscado);
              callableStatement.executeUpdate(); 
              System.out.println("título encontrado: " + callableStatement.getString(2));
              connection.close();
         } catch(Exception e){
            e.printStackTrace();           
         }     
    }
}
