
package ejerciciojdbc7;

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

public class EjercicioJDBC7 {

    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 = "00009";
              CallableStatement callableStatement = connection.prepareCall("{? = call consulta_titulo_fun(?)}");
              callableStatement.registerOutParameter(1,Types.VARCHAR);             
              callableStatement.setString(2, idLibroBuscado);
              callableStatement.executeUpdate();
              System.out.println("título encontrado: " + callableStatement.getString(1));
              connection.close();           
         } catch(Exception e){
            e.printStackTrace();           
         }     
    }   
}
