Results 1 to 2 of 2
  1. #1
    scradi19 is offline Member
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    0

    Default stackoverflowerror

    The error is only showed when i click/choose the combo box,please help me to solve this
    This is my code:(cbkamar is the combo box)

    package astri;
    import java.sql.*;
    import javax.swing.JOptionPane;
    import java.lang.String;
    import javax.swing.table.DefaultTableModel;
    import java.util.Vector;

    /**
    *
    * @author Adi
    */
    public class Penghuni extends javax.swing.JFrame {

    /** Creates new form Penghuni */
    public Penghuni() {
    initComponents();
    txtlaundry.setEditable(false);
    txtlaundry.setText("Mira");
    cbkamar.setSelectedIndex(0);

    }

    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    private void bsimpanMouseClicked(java.awt.event.MouseEvent evt) {
    String nim=txtnim.getText();
    String nama=txtnama.getText();
    String alamat=txtalamat.getText();
    String agama=txtagama.getText();
    String notel=txtnotel.getText();
    String notelot=txtnotelot.getText();
    String kamar= (String)cbkamar.getSelectedItem();
    String laundry=txtlaundry.getText();
    if (nim.equals("")||nama.equals("")||alamat.equals("" )||agama.equals("")||notel.equals("")||notelot.equ als("")||kamar.equals("")||laundry.equals("")){
    JOptionPane.showMessageDialog(null, "Lengkapi data");
    }
    else{
    try
    {
    String url = "jdbc:oracle:thin:@localhost:1521:XE" ;
    String username = "system" ;
    String password = "12345" ;
    Class.forName("oracle.jdbc.driver.OracleDriver").n ewInstance();
    Connection conn = DriverManager.getConnection(url,username,password) ;
    Statement statement=conn.createStatement();
    statement = conn.createStatement();
    String sql="INSERT INTO penghuni VALUES (" + "'" +nim + "', '" + nama + "','"+alamat+"','"+agama+"','"+notel+"','"+notelot +"','"+kamar+"','"+laundry+"')";
    statement.executeUpdate(sql);
    statement.close();
    conn.close();
    JOptionPane.showMessageDialog(null, "Data Telah Masuk");
    }
    catch(Exception e)
    {
    JOptionPane.showMessageDialog(null, "Gagal Menambah Data");
    }
    }
    }

    private void bresetMouseClicked(java.awt.event.MouseEvent evt) {
    txtnim.setText(null);
    txtnama.setText(null);
    txtalamat.setText(null);
    txtagama.setText(null);
    txtnotel.setText(null);
    txtnotelot.setText(null);
    cbkamar.setSelectedIndex(0);
    txtlaundry.setText(null);
    }

    private void bcariMouseClicked(java.awt.event.MouseEvent evt) {
    DefaultTableModel dm1 = ((DefaultTableModel)tabelview.getModel());
    dm1.setNumRows(0);

    DefaultTableModel tabelliat = ((DefaultTableModel)tabelview.getModel());
    try
    {
    String cari=txtcarinim.getText();
    String url = "jdbc:oracle:thin:@localhost:1521:XE" ;
    String username = "system" ;
    String password = "12345" ;
    Class.forName("oracle.jdbc.driver.OracleDriver").n ewInstance();
    Connection con=DriverManager.getConnection(url,username,passw ord);
    Statement state=con.createStatement(ResultSet.TYPE_SCROLL_SE NSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    String sql="SELECT * FROM penghuni WHERE nimdb like '"+cari+"'" ;
    ResultSet rs=state.executeQuery(sql);
    if(rs.next()){
    int j = 1;
    if(tabelview.getRowCount() >= 1)
    for(j = 1; j < tabelliat.getRowCount(); j++)
    tabelliat.removeRow(j);
    do{
    Vector rowVector = new Vector();
    rowVector.addElement(rs.getString(1));
    rowVector.addElement(rs.getString(2));
    rowVector.addElement(rs.getString(3));
    rowVector.addElement(rs.getString(4));
    rowVector.addElement(rs.getString(5));
    rowVector.addElement(rs.getString(6));
    rowVector.addElement(rs.getString(7));
    rowVector.addElement(rs.getString(8));
    ((DefaultTableModel)tabelview.getModel()).addRow(r owVector);
    }while(rs.next());}
    else{
    JOptionPane.showMessageDialog(null, "Data Tidak Ditemukan");
    }
    }
    catch(Exception DBExeption)
    {System.err.println("Error:"+DBExeption);
    }
    }

    private void bviewMouseClicked(java.awt.event.MouseEvent evt) {
    DefaultTableModel dm1 = ((DefaultTableModel)tabelview.getModel());
    dm1.setNumRows(0);

    DefaultTableModel tabelliat = ((DefaultTableModel)tabelview.getModel());
    try
    {
    String url = "jdbc:oracle:thin:@localhost:1521:XE" ;
    String username = "system" ;
    String password = "12345" ;
    Class.forName("oracle.jdbc.driver.OracleDriver").n ewInstance();
    Connection con=DriverManager.getConnection(url,username,passw ord);
    Statement state=con.createStatement(ResultSet.TYPE_SCROLL_SE NSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    String sql="SELECT * FROM penghuni order by namadb asc" ;
    ResultSet rs=state.executeQuery(sql);
    if(rs.next()){
    int j = 1;
    if(tabelview.getRowCount() >= 1)
    for(j = 1; j < tabelliat.getRowCount(); j++)
    tabelliat.removeRow(j);
    do{
    Vector rowVector = new Vector();
    rowVector.addElement(rs.getString(1));
    rowVector.addElement(rs.getString(2));
    rowVector.addElement(rs.getString(3));
    rowVector.addElement(rs.getString(4));
    rowVector.addElement(rs.getString(5));
    rowVector.addElement(rs.getString(6));
    rowVector.addElement(rs.getString(7));
    rowVector.addElement(rs.getString(8));
    ((DefaultTableModel)tabelview.getModel()).addRow(r owVector);
    }while(rs.next());}}
    catch(Exception DBExeption)
    {System.err.println("Error:"+DBExeption);
    }
    }

    private void bhapusMouseExited(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
    }

    private void bhapusMouseClicked(java.awt.event.MouseEvent evt) {
    String nim=txtdelnim.getText();
    if(nim.equals("")){
    JOptionPane.showMessageDialog(null, "Isi NIM yang Ingin Dihapus");
    }
    else{
    try
    {
    String url = "jdbc:oracle:thin:@localhost:1521:XE" ;
    String username = "system" ;
    String password = "12345" ;
    Class.forName("oracle.jdbc.driver.OracleDriver").n ewInstance();
    Connection conn = DriverManager.getConnection(url,username,password) ;
    Statement state=conn.createStatement(ResultSet.TYPE_SCROLL_S ENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    String sql="SELECT * FROM penghuni where nimdb='"+nim+"'order by namadb asc" ;
    ResultSet rs=state.executeQuery(sql);
    if(rs.next()){
    Statement statement=conn.createStatement();
    statement = conn.createStatement();
    String sqll="DELETE FROM penghuni WHERE nimdb='"+nim+"'";
    statement.executeUpdate(sqll);
    statement.close();
    conn.close();
    txtdelnim.setText("");
    JOptionPane.showMessageDialog(null, "Data Telah Dihapus");
    }
    else{
    JOptionPane.showMessageDialog(null, "Data Tidak ditemukan");
    }
    }
    catch(Exception e)
    {
    JOptionPane.showMessageDialog(null, "Data Gagal Dihapus");
    }}
    }

    private void cbkamarItemStateChanged(java.awt.event.ItemEvent evt) {
    if (cbkamar.getSelectedIndex()==0){
    txtlaundry.setText("Mira");
    cbkamar.setSelectedIndex(0);
    } else if (cbkamar.getSelectedIndex()==1){
    txtlaundry.setText("Mira");
    cbkamar.setSelectedIndex(1);
    } else if (cbkamar.getSelectedIndex()==2){
    txtlaundry.setText("Dian");
    cbkamar.setSelectedIndex(2);
    } else if (cbkamar.getSelectedIndex()==3){
    txtlaundry.setText("Dian");
    cbkamar.setSelectedIndex(3);
    } else if (cbkamar.getSelectedIndex()==4){
    txtlaundry.setText("Risa");
    cbkamar.setSelectedIndex(4);
    } else if (cbkamar.getSelectedIndex()==5){
    txtlaundry.setText("Risa");
    cbkamar.setSelectedIndex(5);
    }
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new Penghuni().setVisible(true);
    }
    });
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: stackoverflowerror

    Your code is missing any and all listener code. How are we to know how your code responds to selection events? Also, please read my link below on how to use code tags when posting code.

Similar Threads

  1. StackOverflowError
    By selva.bics in forum AWT / Swing
    Replies: 5
    Last Post: 08-05-2011, 02:09 PM
  2. java.lang.StackOverflowError???
    By remus19 in forum New To Java
    Replies: 6
    Last Post: 05-06-2011, 03:55 AM
  3. Need Help - StackOverflowError - Fibonacci
    By ausglanville in forum New To Java
    Replies: 3
    Last Post: 04-13-2011, 04:43 AM
  4. java.lang.StackoverflowError
    By ravisankarvivek in forum New To Java
    Replies: 6
    Last Post: 06-23-2008, 10:05 AM
  5. java.lang.StackOverflowError
    By eva in forum New To Java
    Replies: 3
    Last Post: 12-24-2007, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •