Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Help! operation not allowed after resultset closed - error

843859Dec 3 2007 — edited Nov 20 2014
HI. I'm having a java.sql.SQLException on my code. I don't understand why the resultset is closed in my try/catch block, since I put the close methods on the finally block.

Please help. I have searched the forum and I did what I could to research on this, but to no avail, i failed.

here is my code:
 private void comboTBMonthItemStateChanged(java.awt.event.ItemEvent evt) {                                              
// TODO add your handling code here:                
       //code, title, gdebit, gcredit, tdebit, tcredit, rdebit, rcredit        == 8 fields
       //fund, daccount, debit, caccount, credit, wtax, dcfa, ccfa,wcfa       
       Connection conn = null, dConn = null;
       Statement stmt = null, dStmt = null;
       ResultSet rs = null, dRs = null;
       String xCode = "", xFund = "";       
       double xDebit = 0, xCredit = 0;
       
       if(evt.getStateChange() == java.awt.event.ItemEvent.SELECTED){
           try{
               Class.forName("com.mysql.jdbc.Driver");
               
               conn = DriverManager.getConnection(accountingLogIn.connectInfo.getUrl(), accountingLogIn.connectInfo.getUser(),
                       accountingLogIn.connectInfo.getPasswd());
               
               dConn = DriverManager.getConnection(accountingLogIn.connectInfo.getUrl(), accountingLogIn.connectInfo.getUser(),
                       accountingLogIn.connectInfo.getPasswd());
               
               stmt = conn.createStatement();
               
               stmt.executeUpdate("DELETE FROM accounting.trialbalance");
               
               rs = stmt.executeQuery(
                       "SELECT daccount, caccount, debit, credit, wtax, LEFT(fund, 2) AS fund " +
                       "FROM accounting.jdv " +
                       "WHERE MONTH(jdvdate) = '"+ comboTBMonth.getSelectedItem() +"' " +
                       "AND YEAR(jdvdate) = '"+comboTBYear.getSelectedItem()+"'");               
               rs.beforeFirst();
               int i = 0, x = 0;
               while(rs.next()){
                   xFund = rs.getString("fund");
                   if(rs.getDouble("debit") != 0){
                        xCode = rs.getString("daccount");
                        xDebit = rs.getDouble("debit");
                        dStmt = dConn.createStatement();
                        dRs = dStmt.executeQuery(
                                "SELECT account, title, gfcredit, gfdebit, tfcredit, tfdebit, rfcredit, rfdebit " +
                                "FROM accounting.trialbalance");
                        dRs.last();
                        i = dRs.getRow();
                        //JOptionPane.showMessageDialog(this, i + " # row in trialbalance");
                        if(i == 0){
                            if(xFund.equals("GF")){
                                dStmt.executeUpdate(
                                        "INSERT INTO accounting.trialbalance" +
                                        "(account, gfdebit)" +
                                        "VALUES('"+ rs.getString("daccount") +"', '"+ rs.getString("debit") +"')");
                            }
                        }
                        else{
                          //  JOptionPane.showMessageDialog(this, i + " with contents");
                            dRs.beforeFirst();
                            int y = 0;
                            while(dRs.next()){
                            //    JOptionPane.showMessageDialog(this, xFund);
                                if(xFund.equals("GF")){
                              //      JOptionPane.showMessageDialog(this, dRs.getString("account") + " trial account");
                                    if(dRs.getString("account").equals(rs.getString("daccount"))){
                                        JOptionPane.showMessageDialog(this, "insert this");
                                        dStmt.executeUpdate(
                                                "UPDATE accounting.trialbalance " +
                                                "SET gfdebit = '"+ (dRs.getDouble("gfdebit") + 5000) +"' " +
                                                "WHERE account = '"+ rs.getString("daccount")+"'");
                                        JOptionPane.showMessageDialog(this, "updated");
                                    }
                                    else{
                                        dStmt.executeUpdate(
                                            "INSERT INTO accounting.trialbalance" +
                                            "(account, gfdebit)" +
                                            "VALUES('"+ rs.getString("daccount") +"', '"+ rs.getString("debit") +"')");
                                    }
                                        
                                }                             
                            }                            
                        }
                   }                            
               }                      
               
               displayTable(tableTB, "SELECT * FROM accounting.trialbalance ORDER BY account", scrollTB, getModelTableTB(), tbwidth);
           }
           catch(SQLException ex){
               JOptionPane.showMessageDialog(this, ex + " A");
           }
           catch(ClassNotFoundException ex){            
           }
           finally{
               try{
                   dRs.close();
                   dRs = null;                   
                   dStmt.close();
                   dStmt = null;
                   rs.close();
                   rs = null;
                   stmt.close();
                   stmt = null;
                   conn.close();
                   conn = null;
               }
               catch(SQLException ex){
                   JOptionPane.showMessageDialog(this, ex + " B");
               }
           }
       }
    }                               

Comments

unknown-698157
The primary reason is
Not reading documentation
As a result
either the character set of the database is incorrect
or
NLS_LANG was incorrect during export or import.

------
Sybrand Bakker
Senior Oracle DBA
Lubiez Jean-Valentin
Hello,
after migration hardcoded arabic characters not displaying properly and privilages are not migrating properly what could be the reason ?
Did you get any message which warms you that there's a possible characterset conversion ?

The easiest way is to migrate your datas into a target database which has the same characterset than the source one. Else, you may care about characterset migration. For instance, you can migrate from US7ASCII to WE8MSWIN1252, ... some charactersets are compatible some other not.

More over, as previously posted, if the NLS_LANG is not well set, it can prevent a correct conversion.

You may have more details on the following link:

http://download.oracle.com/docs/cd/B28359_01/server.111/b28298/ch11charsetmig.htm#CEGCGEAF

About the Privilege, it would be nice that you post the error message. May be, you need to create first a User on the database so as to be able to Grant him the Object Privileges during the Import.


Hope this help.
Best regards,
Jean-Valentin
sb92075
after migration hardcoded arabic characters not displaying properly
One of two reasons are why this occurs
1) data in the new DB is not correct
2) data in the new DB is correct & a data presentation problem exists

You can determine which is the case by issuing simple SELECT as below.

SELECT ASCII_STR(<arabic_column>) from ARABIC_TABLE;

Examine result set to determine is correct data is actually in the DB.
1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 31 2007
Added on Dec 3 2007
6 comments
228 views