Page 7 of 24 First ... 5678917 ... Last
  • Jump to page:
    #91
  1. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    In post#89 in the connectToDB() method, the username and password are obtained from textfields but are NOT tested BEFORE they are used. The code should test that both are valid BEFORE using them to connect to the database.

    The variable: psswrd is given a value BEFORE the user has had a chance to enter anything. The code should wait until the user has pressed the button before getting the values from the textfields.

    I think the errors in post#90 may be because the values used to build the SQL statements are empty.

    Why are there 3 different variables for holding the password?
    One should be enough.
    Last edited by NormR; June 5th, 2013 at 09:02 PM.
  2. #92
  3. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    In post#89 in the connectToDB() method, the username and password are obtained from textfields but are NOT tested BEFORE they are used. The code should test that both are valid BEFORE using them to connect to the database.

    The variable: psswrd is given a value BEFORE the user has had a chance to enter anything. The code should wait until the user has pressed the button before getting the values from the textfields.

    I think the errors in post#90 may be because the values used to build the SQL statements are empty.

    Why are there 3 different variables for holding the password?
    One should be enough.
    What do you suggest? Where should I test the username and password before using it? What should I do to change it? Can you change this forum because I cannot my real code with only posting these codes that show the problem because my whole code is not correct yet?
  4. #93
  5. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    Where should I test the username and password before using it?
    First thing in the listener method.

    What about this:
    Why are there 3 different variables for holding the password?
    One should be enough. Get rid of the other two variables and only use one variable.
  6. #94
  7. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    First thing in the listener method.

    What about this:
    Why are there 3 different variables for holding the password?
    One should be enough. Get rid of the other two variables and only use one variable.
    Here are the updated codes:
    Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package programtesisbaru;
    
    import java.sql.*;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.*;
    
    /**
     *
     * @author Tawi
     */
    public class NewMain extends JFrame {
        JLabel lblNama = new JLabel("Nama : ");
        JTextField txtNama = new JTextField();  
        JLabel kataSandi = new JLabel("Kata Sandi : ");  
        JPasswordField sandiKata = new JPasswordField();  
        JButton masuk = new JButton("Masuk");  
        JButton keluar = new JButton("Keluar"); 
        JButton tombolHubungkankePadukData = new JButton("Hubungkan ke Paduk Data");  
    JButton putuskanKoneksiKePadukData = new JButton("Putuskan Koneksi ke Paduk Data");  
    JButton tombolUbahPadukData = new JButton("Ubah Paduk Data");  
    JButton tombolBatal = new JButton("Batal");
        String namaPengguna1 = new String();  
        String passwordPengguna1 = new String(); 
        Connection connection;  
        Statement statement; 
        JLabel statusMasuk = new JLabel("Belum Masuk");  
        JComboBox jcboURL = new JComboBox (new String[] {"jdbc:odbc:DatabaseKlinik"});  
        JComboBox jcboDriver = new JComboBox (new String[] {"sun.jdbc.odbc.JdbcOdbcDriver"});  
        JLabel statusKoneksi = new JLabel("Tidak ada Koneksi ke Paduk Data");  
        String ax = "Nama Dokter Belum Dimasukkan";   
        String bx = "Nama Dokter atau Kata Sandi tidak Ada";  
        String cx = "Kata Sandi Belum Dimasukkan";  
        String dx = "Nama Dokter Belum Dimasukkan";  
        String ex = "Dokter tidak Dikenal";  
        String fx = "Kata Kunci tidak Benar";  
        String gx = "Nama Pengguna atau Kata Sandi tidak Benar";  
        String hx = "Nama Dokter atau Kata Sandi tidak Ada"; 
        String ix = "Kesalahan";
        String usrname = new String();
        String psswrd = new String();
        
      public NewMain() {  
      
    // Atur letak beberapa komponen  
    setLayout(null);
    lblNama.setBounds(0,10,100,25);  
    add(lblNama);  
    txtNama.setBounds(130,10,200,25);  
    add(txtNama);  
    kataSandi.setBounds(330,10,100,25);  
    add(kataSandi);  
    sandiKata.setBounds(410,10,200,25);  
    add(sandiKata);  
    masuk.setBounds(600,10,100,25);  
    add(masuk);  
    keluar.setBounds(700,10,100,25);  
    add(keluar);  
    tombolHubungkankePadukData.setBounds(0,50,250,25);  
    add(tombolHubungkankePadukData);  
    putuskanKoneksiKePadukData.setBounds(250,50,250,25);  
    add(putuskanKoneksiKePadukData);  
    tombolUbahPadukData.setBounds(480,50,250,25);  
    add(tombolUbahPadukData);  
    tombolBatal.setBounds(730,50,250,25);  
    add(tombolBatal);  
    statusKoneksi.setBounds(800,10,200,25);  
    add(statusKoneksi);  
    tombolHubungkankePadukData.setEnabled(false);  
    putuskanKoneksiKePadukData.setEnabled(false);  
    tombolUbahPadukData.setEnabled(false);    
    tombolBatal.setEnabled(false);   
    statusKoneksi.setVisible(true);  
    lblNama.setVisible(true);  
    txtNama.setVisible(true);  
    kataSandi.setVisible(true);  
    sandiKata.setVisible(true);  
    masuk.setVisible(true);  
    keluar.setVisible(true);  
    masuk.addActionListener(new java.awt.event.ActionListener() {  
                String loginName;  
                String loginPassword;    
                String passwrd;
                @Override  
                public void actionPerformed(java.awt.event.ActionEvent evt) {  
                    usrname = txtNama.getText().trim();  
                    psswrd = new String(sandiKata.getPassword());
                    try {  
                        masuklah();  
                    }   
                    catch (SQLException ex) {
                        ex.printStackTrace();
                        Logger.getLogger(ProgramTesisBaru.class.getName()).log(Level.SEVERE, null, ex);  
                    }  
                }  
      
                private void masuklah() throws SQLException {  
                      if (connection == null)  
                      {  
                          masuk.setEnabled(false);  
                          connectToDB();  
                          entryPrg();  
                      }  
                      else {
                          entryPrg();  
                      }  
                }  
      
                public void connectToDB() {  
                    String uniRL = (String)jcboURL.getSelectedItem();  
                    String driver = (String) jcboDriver.getSelectedItem();  
                    //URL uniRL = (URL)jcboURL.getSelectedItem();  
                    try {  
                        Class.forName(driver);  
                        connection = DriverManager.getConnection(uniRL, usrname, psswrd);  
                        //rowSet.setURL(uniRL);  
                        statusKoneksi.setText("Terhubung ke Paduk Data");  
                    }  
                    catch (java.lang.Exception ex) { 
                        ex.printStackTrace();
                        statusKoneksi.setText("Gagal Terhubung ke Paduk Data");  
                    }  
                }  
      
                private void entryPrg() {  
                          try {
                          statement = connection.createStatement();
                          loginName = "select Nama_Dokter from tblDokterAhli where Nama_Dokter = '"+usrname+"' and Kata_Kunci = '"+psswrd+"'";  
                          //loginPassword = "select Kata_Kunci from tblDokterAhli where Nama_Dokter = '"+usrname+"'";
                          ResultSet logName = statement.executeQuery(loginName);  
                          //ResultSet logPassword = statement.executeQuery(loginPassword);
                          while (logName.next()) 
                               {  
                               namaPengguna1 = logName.getString("Nama_Dokter");  
                               }  
                          //while (logPassword.next()) 
                               //{  
                               //passwordPengguna1 = logPassword.getString("Kata_Kunci");  
                               //}  
                          if (("".equals(usrname)) && ("".equals(psswrd)))   
                                 {  
                                   tombolHubungkankePadukData.setEnabled(false);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   tombolUbahPadukData.setEnabled(false);  
                                   tombolBatal.setEnabled(false);  
                                   masuk.setEnabled(true);
                                   statusKoneksi.setText("Tidak Ada Koneksi ke Paduk Data");
                                   connection.close();
                                   keluar.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   JOptionPane.showMessageDialog(null, gx, ix, JOptionPane.INFORMATION_MESSAGE);  
                                 }  
                        else if ((!"".equals(usrname)) && (!"".equals(psswrd)))  
                           {  
                             if ((!"".equals(namaPengguna1)))   
                                {  
                                   tombolHubungkankePadukData.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(true);  
                                   tombolUbahPadukData.setEnabled(true);  
                                   tombolBatal.setEnabled(true);  
                                   masuk.setEnabled(false);
                                   statusKoneksi.setText("Terhubung ke Paduk Data");
                                   keluar.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(true);  
                                   connection.close();  
                                }  
                             else if (("".equals(namaPengguna1)))  
                                {  
                                   tombolHubungkankePadukData.setEnabled(false);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   tombolUbahPadukData.setEnabled(false);  
                                   tombolBatal.setEnabled(false);  
                                   keluar.setEnabled(true);
                                   masuk.setEnabled(true);
                                   statusKoneksi.setText("Tidak Ada Koneksi ke Paduk Data");
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   JOptionPane.showMessageDialog(null, gx, ix, JOptionPane.INFORMATION_MESSAGE);  
                                   connection.close();  
                               }  
                            /*else if ((!"".equals(passwordPengguna1)))  
                               {  
                                   tombolHubungkankePadukData.setEnabled(false);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   tombolUbahPadukData.setEnabled(false);  
                                   tombolBatal.setEnabled(false);
                                   masuk.setEnabled(true);
                                   statusKoneksi.setText("Tidak Ada Koneksi ke Paduk Data");
                                   keluar.setEnabled(true);  
                                   putuskanKoneksiKePadukData.setEnabled(false);  
                                   JOptionPane.showMessageDialog(null, ex, bx, JOptionPane.INFORMATION_MESSAGE);  
                                   connection.close();  
                               }*/  
        }  
        else if ((!"".equals(usrname)) && ("".equals(psswrd)))
        {  
            if (("".equals(namaPengguna1)))   
            {  
            JOptionPane.showMessageDialog(null, cx, ix, JOptionPane.INFORMATION_MESSAGE);  
              tombolHubungkankePadukData.setEnabled(false);  
              putuskanKoneksiKePadukData.setEnabled(false);  
              tombolUbahPadukData.setEnabled(false);  
              tombolBatal.setEnabled(false); 
              masuk.setEnabled(true);
              statusKoneksi.setText("Tidak Ada Koneksi ke Paduk Data");
              keluar.setEnabled(true);  
              putuskanKoneksiKePadukData.setEnabled(false);  
              connection.close();                          
            }  
            /*else if (("".equals(namaPengguna1)))  
            {  
              tombolHubungkankePadukData.setEnabled(false);  
              putuskanKoneksiKePadukData.setEnabled(false);  
              tombolUbahPadukData.setEnabled(false);  
              tombolBatal.setEnabled(false);
              masuk.setEnabled(true);
              statusKoneksi.setText("Tidak Ada Koneksi ke Paduk Data");
              keluar.setEnabled(true);  
              putuskanKoneksiKePadukData.setEnabled(false);  
              JOptionPane.showMessageDialog(null, cx, bx, JOptionPane.INFORMATION_MESSAGE);                
              connection.close();                          
            }*/  
          /*else if (("".equals(passwordPengguna1)))  
          {  
            tombolHubungkankePadukData.setEnabled(false);  
            putuskanKoneksiKePadukData.setEnabled(false);  
            tombolUbahPadukData.setEnabled(false);  
            tombolBatal.setEnabled(false); 
            masuk.setEnabled(true);
            statusKoneksi.setText("Tidak Ada Koneksi ke Paduk Data");
            keluar.setEnabled(true);  
            putuskanKoneksiKePadukData.setEnabled(false);  
            JOptionPane.showMessageDialog(null, cx, bx, JOptionPane.INFORMATION_MESSAGE);                          
            connection.close();                          
          }*/  
        }  
        else if ((("".equals(usrname)) && (!"".equals(psswrd))))  
        {  
            /*if (("".equals(namaPengguna1)) && ("".equals(passwordPengguna1)))   
          {  
            JOptionPane.showMessageDialog(null, dx, bx, JOptionPane.INFORMATION_MESSAGE);  
            tombolHubungkankePadukData.setEnabled(false);  
            putuskanKoneksiKePadukData.setEnabled(false);  
            tombolUbahPadukData.setEnabled(false);  
            tombolBatal.setEnabled(false);  
            keluar.setEnabled(true);  
            masuk.setEnabled(true);
            statusKoneksi.setText("Tidak Ada Koneksi ke Paduk Data");
            putuskanKoneksiKePadukData.setEnabled(false);                          
            connection.close();                          
          } */ 
        if (("".equals(namaPengguna1)))  
          {  
            tombolHubungkankePadukData.setEnabled(false);  
            putuskanKoneksiKePadukData.setEnabled(false);  
            tombolUbahPadukData.setEnabled(false);  
            tombolBatal.setEnabled(false);  
            keluar.setEnabled(true);  
            masuk.setEnabled(true);
            statusKoneksi.setText("Tidak Ada Koneksi ke Paduk Data");
            putuskanKoneksiKePadukData.setEnabled(false);  
            JOptionPane.showMessageDialog(null, dx, ix, JOptionPane.INFORMATION_MESSAGE);                          
            connection.close();                          
          }  
          /*else if (("".equals(passwordPengguna1)))  
          {  
            tombolHubungkankePadukData.setEnabled(false);  
            putuskanKoneksiKePadukData.setEnabled(false);  
            tombolUbahPadukData.setEnabled(false);  
            tombolBatal.setEnabled(false);  
            keluar.setEnabled(true); 
            masuk.setEnabled(true);
            statusKoneksi.setText("Tidak Ada Koneksi ke Paduk Data");
            putuskanKoneksiKePadukData.setEnabled(false);  
            JOptionPane.showMessageDialog(null, dx, bx, JOptionPane.INFORMATION_MESSAGE);                          
            connection.close();                          
          }  */
        }     
                          }  
                          catch (java.lang.Exception ex){ 
                              ex.printStackTrace();
                              statusMasuk.setText("Gagal Masuk");  
                          }
                }});
    
    keluar.addActionListener(new java.awt.event.ActionListener() {  
                @Override  
                public void actionPerformed(java.awt.event.ActionEvent evt) {  
                    keluar();  
                }  
      
                private void keluar() {  
                    System.exit(0);  
                }  
            });  
      }
        public static void main(String[] args) {
            NewMain mainkan = new NewMain();// TODO code application logic here
            mainkan.setVisible(true);
            mainkan.setTitle("Program Pemilihan Obat dengan Cara Analytic Hierarchycal Process");
            mainkan.setSize(1024,768); 
            mainkan.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
            mainkan.setLocationRelativeTo(null);
        }
    }
    Here are the error codes:

    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(JdbcOdbc.java:7085)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(JdbcOdbc.java:172)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:413)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:396)
    at programtesisbaru.NewMain$1.entryPrg(NewMain.java:131)
    at programtesisbaru.NewMain$1.masuklah(NewMain.java:109)
    at programtesisbaru.NewMain$1.actionPerformed(NewMain.java:93)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    BUILD SUCCESSFUL (total time: 30 seconds)

    Why do I get this code after I reenter the username and password after an error message appear? How to solve this?
  8. #95
  9. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    I don't know how the code gets that error. What has been executed before the error happens?

    Add some println statements what shows where the code has executed and what the values of the variables are where the code has executed so that I can see where the code has executed and what the values of the variables were when the code executed.


    after an error message appear?
    What error message? Where does it appear? What caused the error that makes the error message appear?
    Last edited by NormR; June 6th, 2013 at 11:04 AM.
  10. #96
  11. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    I don't know how the code gets that error. What has been executed before the error happens?

    Add some println statements what shows where the code has executed and what the values of the variables are where the code has executed so that I can see where the code has executed and what the values of the variables were when the code executed.
    After I fill in the username or password with a wrong value and press masuk button, I try to reenter the username or password. That is the moment that make the error happen, what should I do?
  12. #97
  13. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    Please add the println statements I suggested be added in post#95, execute the code, copy what is printed out and paste it here so I can see how the code is executing and what the values of the variables are.

    I don't know what the code is doing. You have changed the DB several times since I created a DB on my PC for testing. I can not test the code now because my DB is different from the one you are using.
  14. #98
  15. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    Please add the println statements I suggested be added in post#95, execute the code, copy what is printed out and paste it here so I can see how the code is executing and what the values of the variables are.

    I don't know what the code is doing. You have changed the DB several times since I created a DB on my PC for testing. I can not test the code now because my DB is different from the one you are using.
    Please tell me the place that I need to put those println statements. Tell me the line number.
  16. #99
  17. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    Put the println statements as the first statement in all methods
    and immediately after a variable is assigned a value:
    Code:
      public void aMethod(){
        System.out.println("aMethod");  // first in a method
        ...
        aVar = value;
        System.out.println("aVar="+aVar);  // after assigning a value to a variable
        ....
    Read the API doc for the createStatement() method. It will throw an exception if the connection is closed.
  18. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    Put the println statements as the first statement in all methods
    and immediately after a variable is assigned a value:
    Code:
      public void aMethod(){
        System.out.println("aMethod");  // first in a method
        ...
        aVar = value;
        System.out.println("aVar="+aVar);  // after assigning a value to a variable
        ....
    Read the API doc for the createStatement() method. It will throw an exceptions if the connection is closed.
    I put a listener for masuk button. Why don't the program execute the listener? If it is executing the listener, it should not throw any exception because before the createStatement, I open the database first. If that is not correct, what code will be a correct code?
    Last edited by Tawijakarta; June 6th, 2013 at 12:00 PM.
  19. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    Is the connection closed when the createStatement() method is executed?

    Adding println statements will help you see where the code is executing and what the data is that the computer sees when the code is executed.
    Without the println() statements, you do not know what the code is doing.
    Last edited by NormR; June 6th, 2013 at 12:01 PM.
  20. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    Is the connection closed when the createStatement() method is executed?

    Adding println statements will help you see where the code is executing and what the data is that the computer sees when the code is executed.
    Without the println() statements, you do not know what the code is doing.
    Yes but every time the user click the masuk button I open the database in the listener. What should I do if that is not correct?
  21. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    Are you sure that you know what the code does when it executes? One way to know is to add some println statements that show where the code executes and what the values of variables are when it executes.

    What should I do
    Add some println statements.
  22. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    Are you sure that you know what the code does when it executes? One way to know is to add some println statements that show where the code executes and what the values of variables are when it executes.


    Add some println statements.
    Here are the results:

    sun.jdbc.odbc.JdbcOdbcStatement@8d41f2
    select Nama_Dokter from tblDokterAhli where Nama_Dokter = 'Kelinci' and Kata_Kunci = ''
    sun.jdbc.odbc.JdbcOdbcResultSet@1e492d8
    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(JdbcOdbc.java:7085)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(JdbcOdbc.java:172)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:413)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:396)
    at programtesisbaru.NewMain$1.entryPrg(NewMain.java:131)
    at programtesisbaru.NewMain$1.masuklah(NewMain.java:109)
    at programtesisbaru.NewMain$1.actionPerformed(NewMain.java:93)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(JdbcOdbc.java:7085)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(JdbcOdbc.java:172)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:413)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:396)
    at programtesisbaru.NewMain$1.entryPrg(NewMain.java:131)
    at programtesisbaru.NewMain$1.masuklah(NewMain.java:109)
    at programtesisbaru.NewMain$1.actionPerformed(NewMain.java:93)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(JdbcOdbc.java:7085)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(JdbcOdbc.java:172)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:413)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:396)
    at programtesisbaru.NewMain$1.entryPrg(NewMain.java:131)
    at programtesisbaru.NewMain$1.masuklah(NewMain.java:109)
    at programtesisbaru.NewMain$1.actionPerformed(NewMain.java:93)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(JdbcOdbc.java:7085)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(JdbcOdbc.java:172)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:413)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:396)
    at programtesisbaru.NewMain$1.entryPrg(NewMain.java:131)
    at programtesisbaru.NewMain$1.masuklah(NewMain.java:109)
    at programtesisbaru.NewMain$1.actionPerformed(NewMain.java:93)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(JdbcOdbc.java:7085)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(JdbcOdbc.java:172)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:413)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:396)
    at programtesisbaru.NewMain$1.entryPrg(NewMain.java:131)
    at programtesisbaru.NewMain$1.masuklah(NewMain.java:109)
    at programtesisbaru.NewMain$1.actionPerformed(NewMain.java:93)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(JdbcOdbc.java:7085)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(JdbcOdbc.java:172)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:413)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:396)
    at programtesisbaru.NewMain$1.entryPrg(NewMain.java:131)
    at programtesisbaru.NewMain$1.masuklah(NewMain.java:109)
    at programtesisbaru.NewMain$1.actionPerformed(NewMain.java:93)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

    What should I do?
  23. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(JdbcOdbc.java:7085)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(JdbcOdbc.java:172)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:413)
    at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.java:396)
    at programtesisbaru.NewMain$1.entryPrg(NewMain.java:131)
    What is the state of the Connection object used for the createStatement() method on line 131? Is it open?

    See posts #99 and #101
    Last edited by NormR; June 7th, 2013 at 10:01 PM.
Page 7 of 24 First ... 5678917 ... Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo