Current location: Hot Scripts Forums » Programming Languages » Everything Java » ERROR: ResultSet not open, operation 'next' not permitted. Verify that autocommit is


ERROR: ResultSet not open, operation 'next' not permitted. Verify that autocommit is

Reply
  #1 (permalink)  
Old 04-12-07, 08:29 PM
qirana qirana is offline
Newbie Coder
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation ERROR: ResultSet not open, operation 'next' not permitted. Verify that autocommit is

hi everybody i need ur help to solve this error.i think it cause by my looping. but i dont know how to solve it. hope somebody will help me.

below is my code:

java Code:
  1. public Vector getForwardPlan()
  2. {
  3.     Vector vPage = new Vector();
  4.     try
  5.     {   
  6.        
  7.         DBConnection dbconn = new DBConnection ();
  8.         stmt = dbconn.getConnection().createStatement();
  9.        
  10.         sql = "SELECT  count (f.plandate) ";
  11.         sql = sql + " FROM forwardplan f, audittypecode a, openfile o, company c ";
  12.         sql = sql + " WHERE f.fileid = o.fileid and ";
  13.         sql = sql + " f.type = a.code and ";
  14.         sql = sql + " o.companyid = c.companyid";
  15.        
  16.         rs = stmt.executeQuery(sql);
  17.         while (rs.next())
  18.         {
  19.             Record = rs.getInt(1);
  20.         }
  21.         rs.close();
  22.         stmt.close();
  23.        
  24.         if (Record > 0)
  25.         {
  26.             stmt = dbconn.getConnection().createStatement();
  27.             sql = "SELECT  f.fileid,f.plandate, a.desc, c.name, c.roc ";
  28.             sql = sql + " FROM forwardplan f, audittypecode a, openfile o, company c ";
  29.             sql = sql + " WHERE f.fileid = o.fileid and ";
  30.             sql = sql + " f.type = a.code and ";
  31.             sql = sql + " o.companyid = c.companyid ";
  32.            
  33.             rs = stmt.executeQuery(sql);
  34.            
  35.             int j = 0;
  36.             int page = 0;
  37.            
  38.             for (int i=1;i<=Record;i++)
  39.             {
  40.                 while (rs.next())
  41.                 {
  42.                     ForwardPlan forwardplan = new ForwardPlan();
  43.                    
  44.                     j++;
  45.                    
  46.                                         forwardplan.setPlandate(rs.getString("plandate"));
  47.                
  48.         String sthn = rs.getString("plandate").substring(0,4);
  49.         String sbln = rs.getString("plandate").substring(5,7);
  50.         String shr = rs.getString("plandate").substring(8,10);
  51.                    
  52.                    
  53.                    int thn = Integer.parseInt(sthn);
  54.                    int bln = Integer.parseInt(sbln);
  55.                    int hr = Integer.parseInt(shr);
  56.                    
  57.         String emeldate = calculateDate(hr, bln, thn);
  58.                    
  59.                    
  60.         String Cdate = forwardplan.getDateToday();
  61.                    
  62.                    
  63.                    
  64.         if (emeldate == Cdate);
  65.         {
  66.            j++;
  67.                        
  68.         forwardplan.setFileid(rs.getString("fileid"));
  69.                         forwardplan.setPlandate(rs.getString("plandate"));
  70.     forwardplan.setDesc(rs.getString("desc"));
  71.     forwardplan.setName(rs.getString("name"));
  72.     forwardplan.setRoc(rs.getString("roc"));
  73.                        
  74.                
  75.     vPage.add(forwardplan);
  76.                        
  77.     if(( j%recordLimit==0))
  78.     {
  79.             vData.add(vPage);
  80.             page = page+1;
  81.                             j=0;
  82.                             vPage= new Vector();
  83.                                                     }
  84.                        
  85.                         if(((Record/recordLimit)==page) && ((j%recordLimit)>0))
  86.                         {
  87.                             page = page + 1;
  88.                             vData.add(vPage);
  89.                            
  90.                            
  91.                         }
  92.                                                            
  93.                     }
  94.                
  95.                 }
  96.                
  97.                 rs.close();
  98.                 stmt.close();
  99.             }
  100.    
  101.            
  102.         }
  103.        
  104.        
  105.     }
  106.    
  107.     catch (SQLException ee)
  108.     {
  109.             System.out.println(ee);
  110.     }
  111.    
  112.     return vData;
  113.  
  114. }

the code is OKuntill at the code : if (emeldate == Cdate);
please help me...thank you in advance

Last edited by Nico; 04-12-07 at 09:04 PM.
Reply With Quote
  #2 (permalink)  
Old 04-12-07, 08:48 PM
ajs5mz2 ajs5mz2 is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Can you run this and post the stacktrace?
__________________
The EBCSNetwork
http://www.ebcsnetwork.net - Website Development
http://www.ebcsnetwork.net/ebcslinks - Link Exchange
Reply With Quote
  #3 (permalink)  
Old 04-14-07, 04:06 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
looking at the title of your topic, i'd say your database isn't executing the query. Have a look at the autocommit setting of your database. It might be that you have to send a command to your database that it execute all entered queries.

I don't think your code works fine until "if (emeldate == Cdate);", as the error clearly says that there's a problem with the ResultSet, which are located above the if.

Replace this:
Java Code:
  1. System.out.println(ee);
with:
Java Code:
  1. ee.printBackTrace();
and post the output, it will tell us a lot more

I assume you're using some class fields, as you don't set the type for certain variables? could you tell us which ones, that would make it easier as well

cheers,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 05:42 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.