2013-01-18 74 views
-3

可能重複:
How to Display next and previous records on clicking on next button in Java如何在Java中顯示一個和下一個記錄

我想顯示從我的數據庫記錄在我的JAVA GUI應用程序。我試圖運行下面的代碼,但後來我得到了不支持操作的異常,不知道最新的錯誤。

private void bt_previousActionPerformed(java.awt.event.ActionEvent evt) { 
     if(evt.getSource()==bt_previous){ 

      DBUtil util = new DBUtil(); 
       try { 
        Connection con = util.getConnection(); 
        PreparedStatement stmt = con.prepareStatement("SELECT [box_no],[weight],[note_state],[dm_state],[1],[2],[5],[10],[20],[50],[100],[500],[1000] FROM [CNV].[dbo].[soil_det] where rm_id=?"); 
        ResultSet rs; 
        String rm = tf_rm_id.getText().trim(); 

        stmt.setLong(1, Long.parseLong(rm)); 

        rs = stmt.executeQuery(); 

        rs.getArray(WIDTH); 
        char n = WIDTH; 
        int i; 
        for (i=0; i<n; i++) { 
         String a = rs.getString("weight"); 
         txtboxwgt.setText(a); 
         String b = rs.getString("note_state"); 
         cbnotstat.setSelectedItem(b); 
         String c = rs.getString("dm_state"); 
         cbdmnstat.setSelectedItem(c); 
         txtboxno.setText(rs.getString("box_no")); 
         txtRe1.setText(rs.getString("1")); 
         txtRs2.setText(rs.getString("2")); 
         txtRs5.setText(rs.getString("5")); 
         txtRs10.setText(rs.getString("10")); 
         txtRs20.setText(rs.getString("20")); 
         txtRs50.setText(rs.getString("50")); 
         txtRs100.setText(rs.getString("100")); 
         txtRs500.setText(rs.getString("500")); 
         txtRs1000.setText(rs.getString("1000")); 
        } 

       } catch (Exception e) { 
         JOptionPane.showMessageDialog(null, e.getMessage()); 
        } 
     } 


    } 

回答

相關問題