Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/01/2012, 23:18
jemycita__
 
Fecha de Ingreso: octubre-2011
Mensajes: 10
Antigüedad: 12 años, 7 meses
Puntos: 0
Exclamación problemas con lista y combobox en netbeans

hola d nuevo... tngo un extraño problema... estoy tratando de llenar una list desde un combobox que a su vez lo lleno desde la base de datos.. pero all correr el programa me sale que hay un error al llenar la lista... estoy trabajando con netbeans y est es mi codigo :

public class categoria extends javax.swing.JFrame {
private Connection con;
private Statement sen;
private ResultSet res;

/** Creates new form categoria */
public categoria() {
initComponents();
cargar_clase();
try
{
sen=con.createStatement();
res=sen.executeQuery("SELECT CAT_NOMBRE FROM TBL_CATEGORIA");
while (res.next())
{
jComboBox1.addItem(res.getString("CAT_NOMBRE"));
}
con.close();
}
catch(Exception e)
{
System.out.println("error al llenar el combo");
}
}

private void consultarActionPerformed(java.awt.event.ActionEven t evt) {
// TODO add your handling code here:
try
{
sen=con.createStatement();
res=sen.executeQuery("SELECT OSC_NOMBRE FROM TBL_OSCAR,TBL_CATEGORIA WHERE CAT_COD=OSC_CATCOD AND CAT_NOMBRE='"+jComboBox1.getSelectedItem()+"'");
list1.clear();
while (res.next())
{
list1.addItem( res.getString("OSC_NOMBRE") );

}
res.close();sen.close();
}
catch (Exception e)
{
System.out.println("Error al llenar la Lista");
} // TODO add your handling code here:

}

private void jComboBox1ActionPerformed(java.awt.event.ActionEve nt evt) {
// TODO add your handling code here:
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.hide();
}

private void list1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
public void cargar_clase()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:proyecto");
}catch (Exception e)
{
System.out.println("error al cargar la clase");
}
}