'number of open cursors exceeded' exception - 10.3.1
Hi All,
We have may DynamicSQL statements fired from our processes due to which we are getting 'number of open cursors exceeded' exception. We don't want to increase the limit of the maximum open cursors. Is there any way to close the cursors explicitly in 10.3.1?
I am aware that when the iterator fetches the last result the cursor gets closed (in the case of any select query) but we have faced the same issue once/twice in the insert query also, is it because we have fired one insert after the other immediately? How much time does a cursor takes to close (implicitly) in the case of insertion of data?
Thanks in advance..
Edited by: GBP on Jan 5, 2011 4:07 AM
Hi,
Please see my post: Re: Cursor closing using DynamicSQL.executeQuery
Hope this helps,
Ariel
Similar Messages
-
Urgent!!! ORA-01000: maximum open cursors exceeded
hello guys, I have done a search in this forum and read plenty of threads, but I didn't find any official answer to this question. In my code, I have closed all the statements and resultsets after using them, but I still got the MAXIMUM OPEN CURSOR exceed exception.
I am not sure whether I close the stmt and rs in the right way. Which one should I close first, the statement or the resultset? Does the order matters??? Thanks a million you can have a good way to solve this problem!!!
Statement st= null;
ResultSet rs = null;
try{
.......// some code
}catch(SQLException sqle){
finally{
if(st!=null)
st.close();
if(rs!=null)
rs.close();The connection I am using is from a pool. I can't close the connection because I need to return it to the pool...
BTW, I just solved the ORA-01100 problem. Here is what I did, I hope it may be helpful.
The original code I have looks like this. That's the code that generates the ORA-01100 exception.
Connection conn = null;
PreparedStatement pstmt= null;
ResultSet rs = null;
try{
conn = Pool.getConection(); // get connection from pool
String sql = "someSQL";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()) {
// do something with the resultset
// here, I reuse the pstmt and rs.
// I think that is what cause the ORA-01000 problem
// because I don't think there is anything wrong
// with the finally block
sql = "another query";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()) {
// do something with the resultset
}catch(SQLException sqle) {
// ignore.......
} finally {
try
if(rs!=null) rs.close();
if(pstmt!=null) pstmt.close();
if(conn != null) Pool.returnConnection(conn); // return connection to pool
} catch(Exception fe) {
}Here is the fixed version of the code that eliminates the ORA-01000 error in my case. If in your code, you re-use your statements, preparedstatments or results, You can try it too.
Connection conn = null;
PreparedStatement pstmt= null;
ResultSet rs = null;
try{
conn = Pool.getConection();
String sql = "someSQL";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()) {
// do something with the resultset
// In the fixed version, I only added the block of
// code below and it solves the problem.
// Before I re-use the preparedstatments,
// statement, and result for a new query,
// I closed them and set them to null.
try {
if(rs != null) rs.close();
if(pstmt != null) pstmt.close();
rs = null;
pstmt = null;
} catch(Exception ie) {
// ignore
sql = "another query";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()) {
// do something with the resultset
}catch(SQLException sqle) {
// ignore.......
} finally {
try
if(rs!=null) rs.close();
if(pstmt!=null) pstmt.close();
if(conn != null) Pool.returnConnection(conn); // return connection to pool
} catch(Exception fe) { -
Sql exception : maximum open cursors exceeded
I run applicatio to insert data into the table, and update data into the table, when it processes more than 800 record, it throws the sql exception :maximum open cursors exceeded.
Who knows the reason?
Thanks.I have a similar problem where in I close the Result set, Statement and close the connection in a finally block. Even though, the connection.close() executes sucessfully, with no exceptions being thrown, I still see the connection opened in ORacle. This builds up connections for our application and by the end of the day we are up with about 500 connections open and rising.
After closing the connection, I did check the value for connection.isClosed() and it still says false (like before the connection was closed). Since we are using a custom Connection manager to pool the connections, my interpretation is that even after the connection is closed, it doesn't get released. I have tried setting the connection to Null, used the finalize method to still check for connection != null and do one more close(), but still the connection is still open.
Am I mistaken in my thinking that even though the connection seems to be closed(), it doesn't get released until the GC runs and picks it for disposal? For every job, after the process is completed we have about 7 open connections and at times the number stays at 7 for some more jobs (Web application driven by servlets and some rmi in the background process). I thne see a surge in the connection after some more jobs are processed and so am not sure whether its the connection manager to blame. Could any one have any pointers on this issue.
Thanks for your response. -
Help needed, getting ORA-01000: maximum open cursors exceeded
CJ or anyone that may have come across this problem in the past, I hope that you may be able to help me
I am trying to implement a function from the Salesforce PHP tool kit that runs against a class that returns a object of ID's that have been updated in a given time frame.
This is a lot of code. I am sorry for that:
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
//Keep the SOAP cache clean
ini_set("soap.wsdl_cache_enabled","0");
$delete_count = 0;
$oracle_deleted = 0;
//Setup array for local ID's'
$opportunity_data = array();
$deleted_data = array();
//start setup for PL SQL statement
$strsql = "begin mapsapp.sforce_opp_insert(";
$strsql .= ":pm_id,";
$strsql .= ":pm_accountid,";
$strsql .= ":pm_name,";
$strsql .= ":pm_description,";
$strsql .= ":pm_stagename,";
$strsql .= ":pm_amount,";
$strsql .= ":pm_probability,";
$strsql .= ":pm_expectedrevenue,";
$strsql .= ":pm_closedate,";
$strsql .= ":pm_type,";
$strsql .= ":pm_nextstep,";
$strsql .= ":pm_leadsource,";
$strsql .= ":pm_isclosed,";
$strsql .= ":pm_iswon,";
$strsql .= ":pm_forecastcategory,";
$strsql .= ":pm_campaignid,";
$strsql .= ":pm_hasopportunitylineitem,";
$strsql .= ":pm_pricebook2id,";
$strsql .= ":pm_ownerid,";
$strsql .= ":pm_createddate,";
$strsql .= ":pm_createdbyid,";
$strsql .= ":pm_lastmodifieddate,";
$strsql .= ":pm_lastmodifiedbyid,";
$strsql .= ":pm_systemmodstamp,";
$strsql .= ":pm_rsm_project_id_score__c,";
$strsql .= ":pm_lead_fae__c,";
$strsql .= ":pm_avg_annual_volume__c,";
$strsql .= ":pm_priority__c,";
$strsql .= ":pm_design_start_date__c,";
$strsql .= ":pm_design_proto_date__c,";
$strsql .= ":pm_production_years__c,";
$strsql .= ":pm_production_life_months__c,";
$strsql .= ":pm_production_months__c,";
$strsql .= ":pm_design_freeze_date__c,";
$strsql .= ":pm_production_proto_date__c,";
$strsql .= ":pm_mass_production_date__c,";
$strsql .= ":pm_fae_status__c,";
$strsql .= ":pm_fae_assigned_date__c,";
$strsql .= ":pm_fae_accepted_date__c,";
$strsql .= ":pm_potential__c,";
$strsql .= ":pm_fae_reject_reason__c,";
$strsql .= ":pm_fae_project_complexity__c,";
$strsql .= ":pm_design_phase__c,";
$strsql .= ":pm_maxim_id__c,";
$strsql .= ":pm_project_number__c,";
$strsql .= ":pm_active__c,";
$strsql .= ":pm_pivotal_created_by__c,";
$strsql .= ":pm_manufactured_by__c,";
$strsql .= ":pm_isdeleted,";
$strsql .= ":pm_lastactivitydate";
$strsql .= "); end;";
//end setup for PL SQL statement
//include common files
require_once ('/users/msimonds/public_html/includes/sfdc.inc');
include_once ('adodb.inc.php');
$db = ADONewConnection("oci8");
//connect to Oracle
$db->Connect('',"database_user","password","dev2");
//$db->BeginTrans();
$db->SetFetchMode(ADODB_FETCH_ASSOC);
if ($db)
try
//Set current time to get records from Salesforce
$currentTime = mktime();
// assume that update occured within the last 24 hrs.
$startTime = $currentTime - (60 * 60 * 36); //(seconds * minutes * hours)
$endTime = $currentTime;
echo "***** Get Updated Opportunities from the last 24 hours *****<br />";
$getUpdateddResponse = $client->getUpdated('Opportunity',$startTime,$endTime);
//$getUpdateddResponse->ids = "";
//echo '<pre>'.print_r($getUpdateddResponse,true).'</pre>';
//exit;
$opportunity_data = $getUpdateddResponse->ids;
if (is_array($opportunity_data) || is_object($opportunity_data))
set_time_limit(0);
ini_set("memory_limit","512M");
//copy data from Object to local array
//count the number of records coming in from Salesforce
$record_count = count($opportunity_data);
echo $record_count;
exit;
//echo '<pre>'.print_r($opportunity_data,true).'</pre>';
//exit;
//loop through the records
for ($i = 0; $i < $record_count; $i++)
$id = $opportunity_data[$i];
//SQL query for Salesforce
$soql = "Select Id, IsDeleted, AccountId, Name, Description, StageName, Amount, Probability, ExpectedRevenue, CloseDate, Type, NextStep, LeadSource, IsClosed, IsWon, ForecastCategory, CampaignId, HasOpportunityLineItem, Pricebook2Id, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, RSM_Original_Project_ID_Score__c, Lead_FAE__c, Avg_Annual_Volume__c, Priority__c, Design_Start_Date__c, Design_Proto_Date__c, Production_Years__c, Production_Life_months__c, Production_Months__c, Design_Freeze_Date__c, Production_Proto_Date__c, Mass_Production_Date__c, FAE_Status__c, FAE_Assigned_Date__c, FAE_Accepted_Date__c, Project_Potential__c, FAE_Reject_Reason__c, FAE_Project_Complexity__c, Design_Phase__c, maxim_id__c, Project_Number__c, Active__c, Project_Comments__c, Pivotal_Created_By__c, Manufactured_By__c FROM Opportunity WHERE Id = '{$id}'";
//setup query to local Oracle MAPS database
$get_oracle_record = query_db($id,$db);
if ($get_oracle_record)
$sql = "DELETE FROM sforce_opportunity WHERE ID = '{$id}'";
if ($db->Execute($sql)) ;
$insert_records = get_records($client,$soql);
else
$insert_records = get_records($client,$soql);
foreach ($insert_records as $r)
$pass_this['id'] = $id;
$pass_this['accountid'] = (string )$r->fields->AccountId;
$pass_this['name'] = (string )$r->fields->Name;
$pass_this['description'] = (string )$r->fields->Description;
$pass_this['stagename'] = (string )$r->fields->StageName;
$pass_this['amount'] = (int)$r->fields->Amount;
$pass_this['probability'] = (int)$r->fields->Probability;
$pass_this['expectedrevenue'] = (int)$r->fields->ExpectedRevenue;
$pass_this['closedate'] = (string )$r->fields->CloseDate;
$pass_this['type'] = (string )$r->fields->Type;
$pass_this['nextstep'] = (string )$r->fields->NextStep;
$pass_this['leadsource'] = (string )$r->fields->LeadSource;
$pass_this['isclosed'] = (string )$r->fields->IsClosed;
$pass_this['iswon'] = (string )$r->fields->IsWon;
$pass_this['forecastcategory'] = (string )$r->fields->ForecastCategory;
$pass_this['campaignid'] = (string )$r->fields->CampaignId;
$pass_this['hasopportunitylineitem'] = (string )$r->fields->HasOpportunityLineItem;
$pass_this['pricebook2id'] = $r->fields->Pricebook2Id;
$pass_this['ownerid'] = $r->fields->OwnerId;
$pass_this['createddate'] = (string )$r->fields->CreatedDate;
$pass_this['createdbyid'] = (string )$r->fields->CreatedById;
$pass_this['lastmodifieddate'] = (string )$r->fields->LastModifiedDate;
$pass_this['lastmodifiedbyid'] = (string )$r->fields->LastModifiedById;
$pass_this['systemmodstamp'] = (string )$r->fields->SystemModstamp;
$pass_this['rsm_project_id_score__c'] = (int)$r->fields->RSM_Original_Project_ID_Score__c;
$pass_this['lead_fae__c'] = (string )$r->fields->Lead_FAE__c;
$pass_this['avg_annual_volume__c'] = (int)$r->fields->Avg_Annual_Volume__c;
$pass_this['priority__c'] = (string )$r->fields->Priority__c;
$pass_this['design_start_date__c'] = (string )$r->fields->Design_Start_Date__c;
$pass_this['design_proto_date__c'] = (string )$r->fields->Design_Proto_Date__c;
$pass_this['production_years__c'] = (int)$r->fields->Production_Years__c;
$pass_this['production_life_months__c'] = (int)$r->fields->Production_Life_months__c;
$pass_this['production_months__c'] = (int)$r->fields->Production_Months__c;
$pass_this['design_freeze_date__c'] = (string )$r->fields->Design_Freeze_Date__c;
$pass_this['production_proto_date__c'] = (string )$r->fields->Production_Proto_Date__c;
$pass_this['mass_production_date__c'] = (string )$r->fields->Mass_Production_Date__c;
$pass_this['fae_status__c'] = (string )$r->fields->FAE_Status__c;
$pass_this['fae_assigned_date__c'] = (string )$r->fields->FAE_Assigned_Date__c;
$pass_this['fae_accepted_date__c'] = (string )$r->fields->FAE_Accepted_Date__c;
$pass_this['project_potential__c'] = (int)$r->fields->Project_Potential__c;
$pass_this['fae_reject_reason__c'] = (string )$r->fields->FAE_Reject_Reason__c;
$pass_this['fae_project_complexity__c'] = (string )$r->fields->FAE_Project_Complexity__c;
$pass_this['design_phase__c'] = (string )$r->fields->Design_Phase__c;
$pass_this['maxim_id__c'] = (string )$r->fields->maxim_id__c;
$pass_this['objective_status_next_qtr__c'] = (string )$r->fields->Objective_Status_Next_Qtr__c;
$pass_this['quality_of_relationship__c'] = (string )$r->fields->Quality_of_Relationship__c;
$pass_this['targeted_po_date__c'] = (string )$r->fields->Targeted_PO_Date__c;
$pass_this['part_no_involved__c'] = (string )$r->fields->Part_No_Involved__c;
$pass_this['first_po_number__c'] = (string )$r->fields->First_PO_Number__c;
$pass_this['lost_reason__c'] = (string )$r->fields->Lost_Reason__c;
$pass_this['fae_estimate_of_business__c'] = (string )$r->fields->FAE_Estimate_of_Business__c;
$pass_this['digital_processor__c'] = (string )$r->fields->Digital_Processor__c;
$pass_this['project_number__c'] = (string )$r->fields->Project_Number__c;
$pass_this['active__c'] = (string )$r->fields->Active__c;
$pass_this['pivotal_created_by__c'] = (string )$r->fields->Pivotal_Created_By__c;
$pass_this['manufactured_by__c'] = (string )$r->fields->Manufactured_By__c;
$pass_this['isdeleted'] = (string )$r->fields->IsDeleted;
$pass_this['lastactivitydate'] = (string )$r->fields->LastActivityDate;
$pass_this['optocon_id__c'] = (string )$r->fields->OptoCon_ID__c;
if (strlen($pass_this['description']) == 0)
$pass_this['description'] = "No Description Posted";
else
$pass_this['description'] = $pass_this['description'];
//echo '<pre>'.print_r($pass_this,true).'</pre>';
//exit;
$record_inserted = insert_record($pass_this,$strsql,$db);
if (!$record_inserted)
//mail('[email protected]','insert error','There was a proble trying to insert a record into the database');
else
echo "Nothing here";
//exit;
//add back in once replication is done
//get deleted records from the Opportunity
$getDeletedResponse = $client->getDeleted('Opportunity',$startTime,$endTime);
//echo '<pre>'.print_r($getDeletedResponse,true).'</pre>';
//exit;
$deleted_ids = $getDeletedResponse->deletedRecords;
//echo '<pre>'.print_r($deleted_ids,true).'</pre>';
if (is_object($deleted_ids))
$temp_array[] = $deleted_ids;
unset($deleted_ids);
$deleted_ids = $temp_array;
$delete_count = count($deleted_ids);
//echo $delete_count;
for ($i = 0; $i < $delete_count; $i++)
$d_id = $deleted_ids[$i];
$id = $d_id->id;
if (query_db($id,$db))
$delete_sql = "Delete from sforce_opportunity WHERE ID = '{$id}'";
$oracle_deleted++;
if ($db->Execute($delete_sql))
echo "<font color=\"#0000FF\">".$id." was removed from the Oracle database</font><br />";
else
echo $id." is not in the Oracle database<br />";
echo $oracle_deleted." records were deleted from Oracle";
catch (exception $e)
$error = '<pre>'.print_r($e,true).'</pre>';
mail('[email protected]','insert error',$error);
$db->CommitTrans();
$db->Close();
exit;
function insert_record($pass_this,$strsql,&$db)
//Prepares PL/SQL Statement
$stmt = $db->Prepare($strsql);
$db->InParameter($stmt,$pass_this['id'],'pm_id');
$db->InParameter($stmt,$pass_this['accountid'],'pm_accountid');
$db->InParameter($stmt,$pass_this['name'],'pm_name');
$db->InParameter($stmt,$pass_this['description'],'pm_description',-1,OCI_B_CLOB);
$db->InParameter($stmt,$pass_this['stagename'],'pm_stagename');
$db->InParameter($stmt,$pass_this['amount'],'pm_amount');
$db->InParameter($stmt,$pass_this['probability'],'pm_probability');
$db->InParameter($stmt,$pass_this['expectedrevenue'],'pm_expectedrevenue');
$db->InParameter($stmt,$pass_this['closedate'],'pm_closedate');
$db->InParameter($stmt,$pass_this['type'],'pm_type');
$db->InParameter($stmt,$pass_this['nextstep'],'pm_nextstep');
$db->InParameter($stmt,$pass_this['leadsource'],'pm_leadsource');
$db->InParameter($stmt,$pass_this['isclosed'],'pm_isclosed');
$db->InParameter($stmt,$pass_this['iswon'],'pm_iswon');
$db->InParameter($stmt,$pass_this['forecastcategory'],'pm_forecastcategory');
$db->InParameter($stmt,$pass_this['campaignid'],'pm_campaignid');
$db->InParameter($stmt,$pass_this['hasopportunitylineitem'],'pm_hasopportunitylineitem');
$db->InParameter($stmt,$pass_this['pricebook2id'],'pm_pricebook2id');
$db->InParameter($stmt,$pass_this['ownerid'],'pm_ownerid');
$db->InParameter($stmt,$pass_this['createddate'],'pm_createddate');
$db->InParameter($stmt,$pass_this['createdbyid'],'pm_createdbyid');
$db->InParameter($stmt,$pass_this['lastmodifieddate'],'pm_lastmodifieddate');
$db->InParameter($stmt,$pass_this['lastmodifiedbyid'],'pm_lastmodifiedbyid');
$db->InParameter($stmt,$pass_this['systemmodstamp'],'pm_systemmodstamp');
$db->InParameter($stmt,$pass_this['rsm_project_id_score__c'],'pm_rsm_project_id_score__c');
$db->InParameter($stmt,$pass_this['lead_fae__c'],'pm_lead_fae__c');
$db->InParameter($stmt,$pass_this['avg_annual_volume__c'],'pm_avg_annual_volume__c');
$db->InParameter($stmt,$pass_this['priority__c'],'pm_priority__c');
$db->InParameter($stmt,$pass_this['design_start_date__c'],'pm_design_start_date__c');
$db->InParameter($stmt,$pass_this['design_proto_date__c'],'pm_design_proto_date__c');
$db->InParameter($stmt,$pass_this['production_years__c'],'pm_production_years__c');
$db->InParameter($stmt,$pass_this['production_life_months__c'],'pm_production_life_months__c');
$db->InParameter($stmt,$pass_this['production_months__c'],'pm_production_months__c');
$db->InParameter($stmt,$pass_this['design_freeze_date__c'],'pm_design_freeze_date__c');
$db->InParameter($stmt,$pass_this['production_proto_date__c'],'pm_production_proto_date__c');
$db->InParameter($stmt,$pass_this['mass_production_date__c'],'pm_mass_production_date__c');
$db->InParameter($stmt,$pass_this['fae_status__c'],'pm_fae_status__c');
$db->InParameter($stmt,$pass_this['fae_assigned_date__c'],'pm_fae_assigned_date__c');
$db->InParameter($stmt,$pass_this['fae_accepted_date__c'],'pm_fae_accepted_date__c');
$db->InParameter($stmt,$pass_this['project_potential__c'],'pm_potential__c');
$db->InParameter($stmt,$pass_this['fae_reject_reason__c'],'pm_fae_reject_reason__c');
$db->InParameter($stmt,$pass_this['fae_project_complexity__c'],'pm_fae_project_complexity__c');
$db->InParameter($stmt,$pass_this['design_phase__c'],'pm_design_phase__c');
$db->InParameter($stmt,$pass_this['maxim_id__c'],'pm_maxim_id__c');
$db->InParameter($stmt,$pass_this['project_number__c'],'pm_project_number__c');
$db->InParameter($stmt,$pass_this['active__c'],'pm_active__c');
$db->InParameter($stmt,$pass_this['pivotal_created_by__c'],'pm_pivotal_created_by__c');
$db->InParameter($stmt,$pass_this['manufactured_by__c'],'pm_manufactured_by__c');
$db->InParameter($stmt,$pass_this['isdeleted'],'pm_isdeleted');
$db->InParameter($stmt,$pass_this['lastactivitydate'],'pm_lastactivitydate');
//executes and loads data coming from salesforce into table
if ($db->Execute($stmt))
echo $pass_this['id']." was inserted into the database<br />";
flush();
unset($pass_this);
unset($stmt);
return true;
else
echo $db->ErrorMsg()."<br>";
mail('[email protected]','database error',$db->ErrorMsg());
return false;
//Get the data from Salesforce to populate Oracle
function get_records(&$connection,&$query)
$queryOptions = new QueryOptions(2000);
$response = new QueryResult($connection->query($query));
// if the size is zero, where done
if ($response->size > 0)
$products = $response->records;
// Cycles through additional responses if the number of records
// exceeds the batch size
while (!$response->done)
set_time_limit(100);
$response = $connection->queryMore($response->queryLocator);
$products = array_merge($products,$response->records);
return $products;
function query_db($id,&$db)
global $db;
$sql = "SELECT *
FROM sforce_opportunity
Where id = '{$id}'";
$rs = $db->Execute($sql);
if ($rs && $rs->_numOfRows > 0)
return true;
else
return false;
exit;
?>the code runs fine and I do not commit my inserts until after I am done retrieving all the records, but I am getting the oracle error: ORA-01000: maximum open cursors exceeded
I am not using any cursors in my PL SQL
CREATE OR REPLACE PROCEDURE MAPSAPP.sforce_opp_insert (
pm_id IN VARCHAR2,
pm_accountid IN VARCHAR2,
pm_name IN VARCHAR2,
pm_description IN VARCHAR2,
pm_stagename IN VARCHAR2,
pm_amount IN NUMBER,
pm_probability IN NUMBER,
pm_expectedrevenue IN NUMBER,
pm_closedate IN VARCHAR2,
pm_type IN VARCHAR2,
pm_nextstep IN VARCHAR2,
pm_leadsource IN VARCHAR2,
pm_isclosed IN VARCHAR2,
pm_iswon IN VARCHAR2,
pm_forecastcategory IN VARCHAR2,
pm_campaignid IN VARCHAR2,
pm_hasopportunitylineitem IN VARCHAR2,
pm_pricebook2id IN VARCHAR2,
pm_ownerid IN VARCHAR2,
pm_createddate IN VARCHAR2,
pm_createdbyid IN VARCHAR2,
pm_lastmodifieddate IN VARCHAR2,
pm_lastmodifiedbyid IN VARCHAR2,
pm_systemmodstamp IN VARCHAR2,
pm_rsm_project_id_score__c IN VARCHAR2,
pm_lead_fae__c IN VARCHAR2,
pm_avg_annual_volume__c IN VARCHAR2,
pm_priority__c IN VARCHAR2,
pm_design_start_date__c IN VARCHAR2,
pm_design_proto_date__c IN VARCHAR2,
pm_production_years__c IN NUMBER,
pm_production_life_months__c IN NUMBER,
pm_production_months__c IN NUMBER,
pm_design_freeze_date__c IN VARCHAR2,
pm_production_proto_date__c IN VARCHAR2,
pm_mass_production_date__c IN VARCHAR2,
pm_fae_status__c IN VARCHAR2,
pm_fae_assigned_date__c IN VARCHAR2,
pm_fae_accepted_date__c IN VARCHAR2,
pm_potential__c IN NUMBER,
pm_fae_reject_reason__c IN VARCHAR2,
pm_fae_project_complexity__c IN VARCHAR2,
pm_design_phase__c IN VARCHAR2,
pm_maxim_id__c IN VARCHAR2,
pm_project_number__c IN VARCHAR2,
pm_active__c IN VARCHAR2,
pm_pivotal_created_by__c IN VARCHAR2,
pm_manufactured_by__c IN VARCHAR2,
pm_isdeleted IN VARCHAR2,
pm_lastactivitydate IN VARCHAR2
IS
BEGIN
INSERT INTO SFORCE_OPPORTUNITY
(id,
accountid,
name,
description,
stagename,
amount,
probability,
expectedrevenue,
closedate,
type,
nextstep,
leadsource,
isclosed,
iswon,
forecastcategory,
campaignid,
hasopportunitylineitem,
pricebook2id,
ownerid,
createddate,
createdbyid,
lastmodifieddate,
lastmodifiedbyid,
systemmodstamp,
rsm_project_id_score__c,
lead_fae__c,
avg_annual_volume__c,
priority__c,
design_start_date__c,
design_proto_date__c,
production_years__c,
production_life_months__c,
production_months__c,
design_freeze_date__c,
production_proto_date__c,
mass_production_date__c,
fae_status__c,
fae_assigned_date__c,
fae_accepted_date__c,
project_potential__c,
fae_reject_reason__c,
fae_project_complexity__c,
design_phase__c,
maxim_id__c,
project_number__c,
active__c,
pivotal_created_by__c,
manufactured_by__c,
isdeleted,
lastactivitydate
VALUES (pm_id,
pm_accountid,
pm_name,
pm_description,
pm_stagename,
pm_amount,
pm_probability,
pm_expectedrevenue,
TO_DATE (SUBSTR (REPLACE (pm_closedate, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_type,
pm_nextstep,
pm_leadsource,
pm_isclosed,
pm_iswon,
pm_forecastcategory,
pm_campaignid,
pm_hasopportunitylineitem,
pm_pricebook2id,
pm_ownerid,
TO_DATE (SUBSTR (REPLACE (pm_createddate, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_createdbyid,
TO_DATE (SUBSTR (REPLACE (pm_lastmodifieddate, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_lastmodifiedbyid,
TO_DATE (SUBSTR (REPLACE (pm_systemmodstamp, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_rsm_project_id_score__c,
pm_lead_fae__c,
pm_avg_annual_volume__c,
pm_priority__c,
TO_DATE (SUBSTR (REPLACE (pm_design_start_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
TO_DATE (SUBSTR (REPLACE (pm_design_proto_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_production_years__c,
pm_production_life_months__c,
pm_production_months__c,
TO_DATE (SUBSTR (REPLACE (pm_design_freeze_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
TO_DATE (SUBSTR (REPLACE (pm_production_proto_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
TO_DATE (SUBSTR (REPLACE (pm_mass_production_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_fae_status__c,
TO_DATE (SUBSTR (REPLACE (pm_fae_assigned_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
TO_DATE (SUBSTR (REPLACE (pm_fae_accepted_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_potential__c,
pm_fae_reject_reason__c,
pm_fae_project_complexity__c,
pm_design_phase__c,
pm_maxim_id__c,
pm_project_number__c,
pm_active__c,
pm_pivotal_created_by__c,
pm_manufactured_by__c,
pm_isdeleted,
TO_DATE (SUBSTR (REPLACE (pm_lastactivitydate, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS')
END sforce_opp_insert;
/I was wondering anyone has seen this before
TIA,
MikeThe code below is deleting fine. Check your $id is valid. I wonder if ADOdb has some quirks with binding and variable creation/destruction, similar to #1 in http://www.oracle.com/technology/tech/php/htdocs/php_troubleshooting_faq.html#bindvars
<?php
See ADOdb Tutorial for Oracle: http://phplens.com/lens/adodb/docs-oracle.htm
drop table mytab;
create table mytab (city varchar2(20), country_id varchar2(20));
insert into mytab values ('SF', 'US');
insert into mytab values ('Sydney', 'AU');
insert into mytab values ('London', 'UK');
commit;
require_once("/home/cjones/public_html/php/adodb5/adodb.inc.php");
$db = ADONewConnection("oci8");
$db->Connect("//localhost/XE", "hr", "hrpwd");
echo "Before:\n";
$rs = $db->Execute("select city from mytab");
while ($arr = $rs->FetchRow()) {
echo $arr['CITY'] . "\n";
$s = $db->Prepare("delete from mytab where country_id = :ci");
$db->Parameter($s, $ci, 'ci');
foreach (array('US', 'AU') as $ci) {
$db->Execute($s);
echo "After:\n";
$rs = $db->Execute("select city from mytab");
while ($arr = $rs->FetchRow()) {
echo $arr['CITY'] . "\n";
?>There's another sample in the ADOdb OCI8 driver:
Usage:
$stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)");
$DB->Bind($stmt, $p1);
$DB->Bind($stmt, $p2);
$DB->Bind($stmt, $p3);
for ($i = 0; $i < $max; $i++) {
$p1 = ?; $p2 = ?; $p3 = ?;
$DB->Execute($stmt);
}For queries I know this works. I haven't seen any examples that prepare once.
$rs = $db->Execute("select city from mytab where country_id = :ci", array('ci' => 'UK'));
while ($arr = $rs->FetchRow()) {
echo $arr['CITY'] . "<br>\n";
} -
ORA-01000: maximum open cursors exceeded ORA-06512
Hi,
An exception error ccurred as below while trying to map a column.
Exception oracle.apps.bne.exception.BneSQLException: SQL Exception in BneFlex.validateSegs: java.sql.SQLException: ORA-01000: maximum open cursors exceeded ORA-06512: at "APPS.FND_MESSAGE", line 525 ORA-06512: at "APPS.FND_MESSAGE", line 565 ORA-06512: at "APPS.FND_MESSAGE", line 654 ORA-06512: at "APPS.FND_MESSAGE", line 766 ORA-06512: at "APPS.FND_MESSAGE", line 741 ORA-06512: at "APPS.FND_FLEX_KEYVAL", line 324 ORA-06512: at line 1 occurred trying to map column: Expense Account.
In alert log file:
Errors in file /vol01/oracle/SIT/db/tech_st/10.2.0/admin/SIT_sit/udump/sit_ora_7
04744.trc:
ORA-07445: exception encountered: core dump [] [] [] [] [] []
ORA-00604: error occurred at recursive SQL level 1
ORA-01000: maximum open cursors exceeded
ORA-01000: maximum open cursors exceeded
Thanks
Edited by: userpat on Aug 15, 2010 5:32 AMHi,
The issue is different this time after restarting application and database find below.
An exception occured trying to map a column
Exception java.lang.ArrayIndexOutOfBoundsException:Array index out of range:1
occured trying to map column:Category
in bne.log
8/18/10 12:08 PM AJPRequestHandler-ApplicationServerThread-2 ERROR BneP
arentMenuResolver.getMenuItem() MENU 101:BUDGET_NOTE - Menu item excluded becaus
e IntegratorAppId and Code does not match that of the Top-Most Menu Item or curr
ent Integrator: 140:FA_MASS_ADDITIONSThe same error is reported in Note: 954462.1 (which is referenced above).
And also let me clear one doubt. v$open_cursors view is used for what?. The total number of count v$open_cursors is 60,000 whereas the parameter is defined only 2000 in the Instance.Cursors Remain Open (in V$OPEN_CURSOR View) after being Closed [ID 1020427.102]
Monitoring Open Cursors & Troubleshooting ORA-1000 Errors [ID 76684.1]
V$OPEN_CURSOR
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2008.htm#REFRN30166
Thanks,
Hussein -
Maximum Open cursor Exceeded error when deleting records from a table
I have a strange problem.
I have a table EMP_MASTER . Whenever I am trying to delete a record from this table, I am getting Maximum no. of open cursor exceeded error. But this error doesnot come when i delete from any other tables. And no. of open cursor is much lesser than OPEN_CURSOR parameter.
All other tables (around 700) has foreign key constraint to this EMP_MASTER table for created_user paramater.
Is it some thing like, when I am trying to delete a record from EMP_master, implicit cursor opens up and checks all referenced tables. and that limit gets exceeded ?
Please help.
Thanks,
RajRaji03 wrote:
There is no trigger defined for this table.
Is there a limit on which no.of references made to a column ? Because one column in this field, Emp no is being referenced in almost every other table. around 700 tables. Will it have any adverse effect ?That should have nothing to do with your problem directly. Again, those tables could have triggers defined on them and you are leaking cursors in one of those triggers (wild guess).
An example of a table with many many others foreign key'd to it.
create table parent_of_everything
column1 number primary key
insert into parent_of_everything select level from dual connect by level <= 1000;
commit;
--create 1000 tables all with foreign keys to the parent_of_everything
begin
for i in 1 .. 1000
loop
execute immediate 'create table child_' || i || ' (column1 number, column2 number, constraint child_' || i || '_fk foreign key (column1) references parent_of_everything (column1) on delete cascade)';
execute immediate 'insert into child_' || i || ' select level, mod(level, ' || i || ') from dual connect by level <= 1000';
commit;
end loop;
end;
TUBBY_TUBBZ?delete parent_of_everything;
1000 rows deleted.
Elapsed: 00:02:53.03No problems were had (none were expected).
Cleanup script.
--remove the 1000 child tables
begin
for i in 1 .. 1000
loop
begin
execute immediate 'drop table child_' || i || ' purge';
exception when others
then
null;
end;
end loop;
end;
/ -
Oracle and "Maximum open cursors exceeded"
Hi,
I am using Weblogic 7.0sp2 with Oracle 9.2.0. Since we are using manual JTA
transactions and the 9.2 drivers are buggy in that respect, we are using the
9.0.1 thin drivers delivered with weblogic.
The problem I have is that after a while, we get the now classic "Maximum open
cursors exceeded" error on connections from our connection pool (used through
a
TX datasource). I have of course checked all our JDBC code and it is fine. We
do not leave any statement/connection open. In fact, I am certain that the
problem is not caused by our applicative code.
The reason I am so positive is that the numbers of open (cached) cursors is
growing, even though there is no activity on our application (I mean no
activity at all). The number of cursors is regurlarly increasing by one
every 5 minutes until it reaches the maximum allowed for a session.
I have listed the statements corresponding to the opened cursors (they
do not belong to our code, as you might have guessed):
SELECT sysdate, user from dual
select longdbcs from javasnm$ where short = :1
select longname from javasnm$ where short = :1
As you can see, there are only three different statements. You can get
the statements from the system view v$open_cursor for a given session
but it will only give one row per different statement. If you want to know
the # of opened cursors in your cursor, use v$sesstat with statistic# = 3
(opened cursor current).
I suspect something is wrong in the connection testing done by weblogic
for the pool (I have activated test on reserved connections and test table
name is "dual") that leaves a resultset/statement behind. What is weird
though is that the refresh period is still 0 (not 5 minutes as you would
expect from the cursor growth rate...).
I would not say that it is an Oracle bug (as stated in some BEA FAQ I read)
since our application JDBC code does not exhibit the same problem. The
problem appeared with recent version of WebLogic for which the session
cursor cache is enabled, I suppose for performance reasons - this
is set by isssuing "ALTER SESSION SET SESSION_CACHED_CURSORS = ...".
Talking about this, does anybody know to which value WebLogic sets this
parameter when intializing the connection (this is neither
documented/configurable)?
Up to now, I have come up with possibly two workarounds, neither of which
is satisfying:
- resetting the pool from time to time
- issuing "ALTER SESSION SET SESSION_CACHED_CURSORS = 0" when I get a
connection from the pool. I have not tested this one personally (read
in a newsgroup that someone else did successfully) but it is supposed
to reset the cursor cache that is causing the trouble.
Any help will be greatly appreciated,
Regards,
Thierry.Thierry Rouget wrote:
Hi,
I am using Weblogic 7.0sp2 with Oracle 9.2.0. Since we are using manual JTA
transactions and the 9.2 drivers are buggy in that respect, we are using the
9.0.1 thin drivers delivered with weblogic.
The problem I have is that after a while, we get the now classic "Maximum open
cursors exceeded" error on connections from our connection pool (used through
a
TX datasource). I have of course checked all our JDBC code and it is fine. We
do not leave any statement/connection open. In fact, I am certain that the
problem is not caused by our applicative code.
The reason I am so positive is that the numbers of open (cached) cursors is
growing, even though there is no activity on our application (I mean no
activity at all). The number of cursors is regurlarly increasing by one
every 5 minutes until it reaches the maximum allowed for a session.
I have listed the statements corresponding to the opened cursors (they
do not belong to our code, as you might have guessed):
SELECT sysdate, user from dual
select longdbcs from javasnm$ where short = :1
select longname from javasnm$ where short = :1
As you can see, there are only three different statements. You can get
the statements from the system view v$open_cursor for a given session
but it will only give one row per different statement. If you want to know
the # of opened cursors in your cursor, use v$sesstat with statistic# = 3
(opened cursor current).
I suspect something is wrong in the connection testing done by weblogic
for the pool (I have activated test on reserved connections and test table
name is "dual") that leaves a resultset/statement behind. What is weird
though is that the refresh period is still 0 (not 5 minutes as you would
expect from the cursor growth rate...).
I would not say that it is an Oracle bug (as stated in some BEA FAQ I read)
since our application JDBC code does not exhibit the same problem. The
problem appeared with recent version of WebLogic for which the session
cursor cache is enabled, I suppose for performance reasons - this
is set by isssuing "ALTER SESSION SET SESSION_CACHED_CURSORS = ...".
Talking about this, does anybody know to which value WebLogic sets this
parameter when intializing the connection (this is neither
documented/configurable)?
Up to now, I have come up with possibly two workarounds, neither of which
is satisfying:
- resetting the pool from time to time
- issuing "ALTER SESSION SET SESSION_CACHED_CURSORS = 0" when I get a
connection from the pool. I have not tested this one personally (read
in a newsgroup that someone else did successfully) but it is supposed
to reset the cursor cache that is causing the trouble.
Any help will be greatly appreciated,
Regards,
Thierry.Hi. We don't make those queries either. I suspect they are internal to the
oracle driver. One thing you can try is to set the size of the pool's
statement cache to zero. Oracle will retain cursors for every statement we
cache. The alternative is also to tell the DBMS to allow a given session
more cursors.
Joe -
Open cursors exceeded - common problem, different scenario
I searched both the web and the java forums and found the "maximum open cursors exceeded" to be a very common problem, one in which I have, but I can't seem to solve it and I was wondering if the way I am doing certain things are causing it.
Here is my program. I have a java server running that is acting as a midway between a java applet and an Oracle database. Since many users will most likely be using the applet, and since the applet has the ability to alter data in the database, I wanted to Synchronize my database connections.
So because of this, my server has a static class with all the database calls, including a connection call that connects to the database when it is first started up. Also, I return ResultSets to the server, but I never close either my ResultSet or my Statement. I do this because I only have one global of each of them. Otherwise I would have to close them from the server, and this worries me as far synchronization goes. Thus, with a global statement, I am just reinstantiating it every time. This may very well be my problem.
Should I?
1. Not have a single connection to the database but instead create a new connection every time a database call is made?
2. Do not make the resultset and statement global. (And if this is yes, how would I go about closing them after I return the result set to the server).
3. Leave the resultset and statement global but go ahead and try to close them from the server.
4. Or any combination of the above.
Thanks. I appreciate any help advance. This problem has been driving me insane the last couple of days. If it would help to post my database connections code then I will gladly do so.Hmmm. I have worked on it all day and still have nothing. If anyone has even a shred of help, that would be greatl appreciated. I am going to just go ahead and post my code just in case that helps anyone.
import java.net.*;
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
class DBOracleCon
final static String DBHostName = "hostname",
DBPortNumber = "12345",
DBId ="myid";
final static String UserName = "user",
Password = "password";
private static Connection con;
private static Statement stmt;
private static ResultSet rs;
static protected void dbConnection ()
try
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String dbConnectString =
"(DESCRIPTION=(ADDRESS=(HOST=" + DBHostName + ")"+
"(PROTOCOL=tcp)(PORT="+ DBPortNumber + "))"+
"(CONNECT_DATA=(SID="+ DBId + ")))";
con = DriverManager.getConnection(
"jdbc:oracle:thin:@"+dbConnectString,
UserName, Password);
con.setAutoCommit(false);
catch (Exception e)
System.out.println ("Connection Error:" + e);
static public synchronized Connection returnConnection ()
return con;
static protected synchronized ResultSet executeQuery (String query)
try
stmt = con.createStatement();
//System.out.println ("QUERY: " + query);
rs = stmt.executeQuery (query);
return rs;
catch (Exception e)
System.out.println (e);
e.printStackTrace();
return null;
static protected synchronized ResultSet executeQuery (PreparedStatement ps)
try
rs = ps.executeQuery();
return rs;
catch (Exception e)
System.out.println (e);
e.printStackTrace();
return null;
static protected synchronized void executeUpdate (String query)
try
stmt = con.createStatement();
System.out.println ("UPDATE: " + query);
stmt.execute (query);
commit();
catch (Exception e)
System.out.println (e);
e.printStackTrace();
static protected void executeUpdate (PreparedStatement ps)
try
ps.executeUpdate();
commit();
catch (Exception e)
System.out.println (e);
e.printStackTrace();
static private void commit ()
try
stmt = con.createStatement();
stmt.execute ("commit");
catch (Exception e)
System.out.println (e);
}Thanks. -
How to get highest number of open cursors within the current calendar day
Hi all ,
i need to know how to get the highest number of open cursors within the current calendar day.
Thanks ,823030 wrote:
the issue is my customer is getting the error ORA-01000: maximum open cursors exceeded and we need an sql statment that gets the following values :
-highest number of open cursors experienced in the current calendar day.
-current open cursors
-and maximum open cursorsThis error is rare. It happens when
a) the value of the open cursor parameter is set extremly low (default is something like 1000). Low would be something like 10.
b) <strike>you have many concurrent users(=sessions) and </strike>the application does not use bind values
In this case each select will open a new cursor, instead of reusing it.
c) you have a select that opens a cursor for each line. This can happen with a statement where you have the CURSOR keyword somewhere in the select or where clause. Those cursors will be closed when the select is finished. But during the run time of the select, all cursors stay open.
To track the number of "open cursors" during the day you would need to implement some monitoring. Maybe based on the view that was already mentioned.
Edited by: Sven W. on May 16, 2011 2:30 PM - since the parameter is on session level, other open cursors should not influence it much. -
Maximum open cursors exceeded with Sybase TG
Hi,
Does anyone knows if we can use the HS_OPEN_CURSORS with Oracle transparent gateway for Sybase ?
I've got the error message :
ORA-01000: maximum open cursors exceeded
ThanksThis depends if the maximum number of cursors exceeded in the GTW or within the db.
In my eyes the OPEN_CURSORS of the db is normally the limiting factor.
HS_OPEN_CURSORS defines the maximum number of cursors that can be open on one connection to a non-Oracle system instance.
The value never exceeds the number of open cursors in the Oracle database server. Therefore, setting the same value as the OPEN_CURSORS initialization parameter in the Oracle database server is recommended.
So better check out the OPEN_CURSORS of the db and increase them. -
SQLException: maximum open cursors exceeded
hi all,
i get the following exception when executing my program.
14:36:02,111 ERROR [STDERR] java.sql.SQLException: ORA-01000: maximum open cursors exceeded
14:36:02,111 ERROR [STDERR] at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
14:36:02,111 ERROR [STDERR] at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
14:36:02,111 ERROR [STDERR] at oracle.jdbc.ttc7.Oopen.receive(Oopen.java:120)
14:36:02,111 ERROR [STDERR] at oracle.jdbc.ttc7.TTC7Protocol.open(TTC7Protocol.java:586)
14:36:02,127 ERROR [STDERR] at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:385)
14:36:02,127 ERROR [STDERR] at oracle.jdbc.driver.OracleConnection.privateCreateStatement(OracleConnection.java:772)
14:36:02,127 ERROR [STDERR] at oracle.jdbc.driver.OracleConnection.createStatement(OracleConnection.java:712)
14:36:02,127 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedConnection.createStatement(WrappedConnection.java:145)
14:36:02,127 ERROR [STDERR] at abcd.updateMethod(abcd.java:1605)
14:36:02,127 ERROR [STDERR] at servlet.abcdServlet.doPost(abcdServlet.java:62)
14:36:02,127 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
14:36:02,127 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
14:36:02,143 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
14:36:02,143 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
14:36:02,143 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
14:36:02,143 ERROR [STDERR] at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
14:36:02,143 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
14:36:02,143 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
14:36:02,143 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
14:36:02,143 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
14:36:02,143 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)the code is like this
while (result.next())
String sql = "update query";
Statement = null;
st = con.createStatement(); // line No. 1605
st.executeUpdate(sql);
st.close();
}anyone had such experience? please post your valuable suggestions.You have better to select your data (select connection) and store them in an arraylist for example, then close the 'select connection' and finally
loop through the arraylist and make as much update as the list size.I disagree. Huge amounts of data could be being pulled from the database (that is one of their strength) and if the data can be processed one row at a time there is no reason to load it all into memory.
=> take a look [here |http://java.sun.com/docs/books/tutorial/jdbc/TOC.html]
and [here |http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html] for preparedstatements
Ditto to PreparedStatement
OP. Is it possible that the Statement being returned (from what looks like JBoss) has the close method overwritten and does not actually return the resource (some type of pooling)? -
Maximum open cursors exceeded prblm , code attached for review
I am getting the following exception in my code
java.sql.SQLException: ORA-01000: maximum open cursors exceeded
My code is as follows
public ResultSet getFiles() throws Exception
ResultSet rs = null;
PreparedStatement pst = null;
String fileqry = "select * from FILES_SENT where FILESTATUS= 'TOBS' ";
pst = connection.prepareStatement(fileqry);
try
rs = pst.executeQuery();
catch(Exception e)
System.out.println("In getFiles" + e );
System.exit(0);
return rs;
public void RUN()
while(true)
try
System.out.println("opening cursor " );
FileResultSet = getFiles(); // polling the DB for new messages
if (FileResultSet!= null && FileResultSet.next()) // if new files are found
do // for each of the records
String Filename = FileResultSet.getString("FILENAME");
System.out.println("Processing the file " + Filename);
// getting the messagetype from the filename
String MessageType= Filename.substring(0,1);
String InternalMessageID = getInternalMessageID(MessageType);
System.out.println("internalmessageid of the file " + InternalMessageID);
while (FileResultSet.next());
System.out.println("Processed all messages");
else
System.out.println("closing cursor " );
FileResultSet.close();
Thread.sleep(10);
catch(Exception f)
System.out.println("exception in RUN " + f);
System.exit(0);
}The database is oracle 10g
The loop is going for 300 times with out any data and then comes down with this exception.
Experts please give your valuable help in this.
DineshI had previously tried to close the statement
immediately after the exceute statement , but the
resultset is lost after that .
So where shoud i close the statement ?Don't keep ResultSets around! See this whole thread:
http://forum.java.sun.com/thread.jspa?threadID=788017
You should:
1. Open connection
2.Open statement
3.Get ResultSet
4.Convert ResultSet into something better
5. close ResultSet
6.close statement
7.close connection
8. return the "something better you converted the ResultSet into"
Of course 5,6,7 should be coded in a way they ALWAYS get executed regardless of any exception may occur (for example in finally block).
1 to 8 may also be replaced by (unless your purpose is only to learn JDBC basics):
1. use some kind of high level framework/library/standard (Hibernate,Ibatis,JPA if you use Java 1.5+... you name it, there are as much as you may need, or maybe even a few more!)
Hope this helps,
Riccardo -
In java/jsp got Error,ORA-01000: maximum open cursors exceeded,
Dear ALL,
We are facing a problem of in java/jsp. ORA-01000: maximum open cursors exceeded,We are using referance Cursor for returing the Record in java file.
The Code is given below.
import java.sql.*;
import javax.sql.*;
import com.india.trade.dbConnection.*;
import oracle.jdbc.driver.*;
import java.util.Vector ;
public class IntRmsActivity
private static JDBCConnection instance = null;
private static Connection con = null;
private static CallableStatement stmt_admin_getadmins = null;
private static String str_admin_getadmins = "{ call Admin_conf.RMS_ADMIN_GETALLADMINS(?,?) }";
static
try
instance = new JDBCConnection();
con = instance.getConnection();
stmt_admin_getadmins = con.prepareCall(str_admin_getadmins);
}catch(Exception se){se.printStackTrace();}
public static Vector admin_getAdmins() throws Exception
checkconnection();
String message = null;
Vector v_admins = new Vector();
ResultSet rs_admins = null;
stmt_admin_getadmins.registerOutParameter(1 , OracleTypes.CURSOR);
stmt_admin_getadmins.registerOutParameter(2 , Types.VARCHAR);
stmt_admin_getadmins.execute();
message = stmt_admin_getadmins.getString(2);
System.out.println("message " + message);
rs_admins = ((OracleCallableStatement)stmt_admin_getadmins).getCursor(1);
while (rs_admins.next())
v_admins.addElement(rs_admins.getString("adminid"));
rs_admins.close();
return v_admins;
CREATE OR REPLACE PACKAGE Admin_conf IS
TYPE REF_CRSR IS REF CURSOR; /* OUTPUT CURSOR VARIABLE TYPE */
PROCEDURE RMS_ADMIN_GETALLADMINS(RESULTS OUT REF_CRSR,
OUT_MESSAGE OUT VARCHAR2);
END Admin_conf;
CREATE OR REPLACE PACKAGE BODY Admin_conf
IS
PROCEDURE RMS_ADMIN_GETALLADMINS(RESULTS OUT REF_CRSR,
OUT_MESSAGE OUT VARCHAR2)
IS
l_ref_out_crsr REF_CRSR;
BEGIN
OPEN l_ref_out_crsr FOR
SELECT EXECUTIVE_ID adminid
FROM MASTER_EXECUTIVE_ID
ORDER BY EXECUTIVE_ID;
OUT_MESSAGE := 'ADMIN IDS FETCHED SUCCESSFULLY';
RESULTS := l_ref_out_crsr;
EXCEPTION WHEN OTHERS THEN
OUT_MESSAGE := 'ERROR ' || SUBSTR(SQLERRM, 1, 60);
END RMS_ADMIN_GETALLADMINS;
END Admin_conf;
Regards
Ajay Singh RathodAre you actually closing the connections, resultsets in all cases?
From what you've posted you call
rs_admins.close();but in that method, you propagate any exceptions that occur out to the caller method, which in turn just prints a stack trace.
So if an exception occurs before you call the rs_admin.close() the result set will never be closed as the statement won't be reached.
I'd add a speific exception handling routine to the admin_getAdmins() method and include a finally clause to close the result set in all cases. You can still onthrow the exception if you want.
cheers
-steve- -
How to analyse the number of open cursors being used by each program?
Hi,
I am getting an error "ORA:1000 Maximum Open Cursors Exceeded" in my
application. I want to analyse and monitor that how many cursors are
being used by each program running in a particular session. I have
already set the Open Cursors Count double of the recommended for my
application, yet I am getting this error.
Is there any tool to analyse and monitor the number of cursors being
used by each DB call?
I have installed SAP NW 7.0 and Using Oracle 10g as DB.
Your immediate help will be greatly appreciated.
Best Regards,
Smriti.You can list the open cursors per session and check which one uses the most with sqlplus:
SQL> select a.value, s.username, s.sid, s.serial#
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic# and s.sid=a.sid
and b.name = 'opened cursors current';
Values over 300 are unusual.
It is quite possible, that you see several workprocesses using a lot, because workprocesses are kind of shared sessions.
Cheers Michael
Edit: ah, our posts crossed, obviously there is no workprocess in the java world -
ORA-01000 maximum open cursors exceeded with XA driver
We are getting ORA-01000 maximum open cursors exceeded error from Oracle database
agian and again.We are usimg XA driver.
What is the weblogic's work around to handle this error?How we can handle this?We
tried doing "grant select on DBA_PENDING_TRANSACTIONS to public ;" ,this also
works for some time only.Again the same error starts coming.
Help please.
Thanx in advance.Thanks for your reply.
I have increased my cursor size to 2000(default 300).We are using weblogic6.1
and Oracle9i.Yes I was little aware about this bug so I tried doing "grant select
on DBA_PENDING_TRANSACTIONS to public " from sys and no of open cursors reduced
drastically but aftter some time increased again.We are using combination of thin,XA,non
XA and oci drivers.
We are using weblogic security framework also in our application and I think that
consumes maximum no. of cursors.
Kindly advice.
Thanx a lot.
Pinky
Mitesh Patel <[email protected]> wrote:
What is the size of cusror set in your oracle init.ora file?
What version of oracle thin driver and weblogic are you using?
Please read the following note:
There is a bug with Oracle 817 driver's XAResource.recover implementation:
it
ignores the flag and always return all in-doubt Xids. After initially
calling a resource's recover with TMSTARTRSCAN, TM subsequently calls
the
resource's recover with TMNOFLAGS until no more Xid is returned. Thus,
Oracle driver's XAResource.recover is called infinitely until eventually
it
returns XAER_RMERR. Subsequent XAResource.start then returns ORA-01000
exception (looks like all their XAResource methods internally uses prepared
statements to execute some stored procedure.)
Is this the case wth you?
Mitesh
Pinky Arora wrote:
We are getting ORA-01000 maximum open cursors exceeded error from Oracledatabase
agian and again.We are usimg XA driver.
What is the weblogic's work around to handle this error?How we canhandle this?We
tried doing "grant select on DBA_PENDING_TRANSACTIONS to public ;",this also
works for some time only.Again the same error starts coming.
Help please.
Thanx in advance.
Maybe you are looking for
-
I am really sorry but I am still stuck. Please help.
Please can someone help me with the following code. I have a number of questions. So far all buttons that I have coded actions for work fine. When The program saves it does it correctly as I have seen the text file. However I have some problems. 1) H
-
Problem: package javax.servlet.jsp does not exist
I am a novice JSP programmer. My projects that use any javax.servlet classes are not seeing those at all. I am working with a group of folks using Java SE 1.5. (Note: I'm using Windows so the directory separator is "\") What Used to work: 1. Nearly a
-
Cannot fill path correctly after using image trace.
When I pull a regular 2-color photo from the web and use the tracing option, selecting ignore white, then expanding it into a path, it will not fill correctly. Instead of filling the object created, it fills the entire photo area of the original ima
-
I am a photographer now i am using snow leapord my pictures are stored on a 1.5 gb external drive . But now i am useing icloud on my ipad , but i am not able to use icoud .photostream on my mac with snow leapord , so i am considering upgrading to li
-
Hi I have a forest (Internal) and I have another forest (External). SCCM 2012 R2 and SQL 2012 is installed in the "internal forest", I would like to add a new forest (external) to my SCCM setup which is "Untrusted". The two forests are not trusted a