import java.awt.*; import java.awt.event.*; import java.util.*; import java.sql.*; public class CallableSQL extends Frame { TextArea tarea; Connection c; public CallableSQL () { super("CallableSQL"); // create a connection to the database try { String driverName = "sun.jdbc.odbc.JdbcOdbcDriver"; Driver driver = (Driver)Class.forName(driverName).newInstance(); Properties p = new Properties(); p.put("user", "p8cp1"); p.put("password", "ismael"); String dbURL = "jdbc:odbc:fiaa"; c = driver.connect(dbURL, p); System.out.println("--- Conection established ---"); } catch (Exception e) {} tarea = new TextArea(20,60); this.add("Center", tarea); this.setSize(300,300); this.setVisible( true ); //Add ActionListener para Fechar Aplicacao this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); try { // Create the sql that will be executed String sql = "execute getPessoas ?"; CallableStatement call = c.prepareCall(sql); // declare an integer value and set it for the // first parameter int i = 0; call.setInt(1, i); // register the first parameter as an integer call.registerOutParameter(1, Types.INTEGER); // execute the stored procedure call.execute(); // get the returned count i = call.getInt(1); // display the returned result tarea.setText("Existem " + Integer.toString(i) + " Pessoas cadastradas !!!"); } catch (SQLException e) {} } public static void main (String args[]) { CallableSQL app = new CallableSQL(); } }