Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/11/2011, 21:51
VivaElPirateo
 
Fecha de Ingreso: septiembre-2011
Mensajes: 40
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: Problemas con Botón Java y Procedimiento almacenado

Modifiqué el botón de modificar de tal manera:


private void CMD_ModificarActionPerformed(java.awt.event.ActionEvent evt) {

DefaultComboBoxModel modelo = new DefaultComboBoxModel();

cboModificarConstructora.setModel(modelo);

modelo.addElement("Seleccione un ID");
cboModificarConstructora.setModel(modelo);

String id_constructora = cboModificarConstructora.getSelectedItem().toStrin g();
String nombre_constructora = txtModificaNombreConstru.getText().toUpperCase();
String direccion_constructora = txtModificaDireccionConstru.getText().toUpperCase( );
int telefono_constructora = Integer.parseInt(txtModificaTelefonoConstru.getTex t());
String contacto_constructora = txtModificaContactoConstru.getText().toUpperCase() ;


String driver = "oracle.jdbc.driver.OracleDriver";
String dsn = "jdbc:oracle:thin:@localhost:1521:XE";
String sql = "{call SP_IngresarConstructora(?,?,?,?,?)}";


String usuario = "tallerbd";
String password = "oracle";

try {

Class.forName(driver);
Connection con = DriverManager.getConnection(dsn, usuario, password);
CallableStatement cstmt = con.prepareCall(sql);
PreparedStatement ps = con.prepareStatement(sql);

ResultSet rs = ps.executeQuery(); //ResultSet lo q es en VB Recordset

cstmt.setString(1,id_constructora);
cstmt.setString(2,nombre_constructora);
cstmt.setString(3,direccion_constructora);
cstmt.setInt(4,telefono_constructora);
cstmt.setString(5,contacto_constructora);

if (cstmt.execute()) {
JOptionPane.showMessageDialog(null, "La Constructora no pudo ser modificada");
} else {
JOptionPane.showMessageDialog(null, "Datos modificados correctamente");
}

while(rs.next()){

modelo.addElement(rs.getObject("rut"));
cboModificarConstructora.setModel(modelo);
}

rs.close();
} catch (SQLException ex) {
Logger.getLogger(Constructora.class.getName()).log (Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Constructora.class.getName()).log (Level.SEVERE, null, ex);

}
}


Pero ahora me sale el siguiente error:

java.sql.SQLException: Falta el parámetro IN o OUT en el índice:: 1
at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:146)
at oracle.jdbc.driver.OraclePreparedStatement.process CompletedBindRow(OraclePreparedStatement.java:1681 )
at oracle.jdbc.driver.OraclePreparedStatement.execute Internal(OraclePreparedStatement.java:3280)
at oracle.jdbc.driver.OraclePreparedStatement.execute Query(OraclePreparedStatement.java:3329)
at gui.Constructora.CMD_ModificarActionPerformed(Cons tructora.java:697)
at gui.Constructora.access$300(Constructora.java:35)
at gui.Constructora$4.actionPerformed(Constructora.ja va:304)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.jav a:6504)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3321)
at java.awt.Component.processEvent(Component.java:626 9)
at java.awt.Container.processEvent(Container.java:222 9)
at java.awt.Component.dispatchEventImpl(Component.jav a:4860)
at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
at java.awt.Component.dispatchEvent(Component.java:46 86)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4422)
at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2713 )
at java.awt.Component.dispatchEvent(Component.java:46 86)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:707)
at java.awt.EventQueue.access$000(EventQueue.java:101 )
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 677)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:90)


Ayuda, por favor!!!