DataReader is not closed??

5 views
Skip to first unread message

Jason

unread,
Feb 19, 2008, 6:11:21 AM2/19/08
to Quartz.NET
Hello Sir,

I am trying to update a exist dailyCalendar

_sched.AddCalendar(calendarName, triggerAdapter.QuartzCalendar, true,
true);

However, it always throw a sql Exception ( error message look like
other data reader is exist and should be closed firstly...)

stack:


System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand
command)

System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String
method, SqlCommand command)
於 System.Data.SqlClient.SqlCommand.ValidateCommand(String method,
Boolean async)
於 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result)
於 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method)
於 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method)

System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior)

System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()

Quartz.Impl.AdoJobStore.StdAdoDelegate.SelectTrigger(ConnectionAndTransactionHolder
conn, String triggerName, String groupName) 於 \Quartz\Impl\AdoJobStore
\StdAdoDelegate.cs: Line 1752

Quartz.Impl.AdoJobStore.StdAdoDelegate.SelectTriggersForCalendar(ConnectionAndTransactionHolder
conn, String calName) 於 \Quartz\Impl\AdoJobStore\StdAdoDelegate.cs:
Line 1684

Quartz.Impl.AdoJobStore.JobStoreSupport.StoreCalendar(ConnectionAndTransactionHolder
conn, SchedulingContext ctxt, String calName, ICalendar calendar,
Boolean replaceExisting, Boolean updateTriggers) 於 \Quartz\Impl
\AdoJobStore\JobStoreSupport.cs: Line 1843

Jason

unread,
Feb 19, 2008, 6:30:29 AM2/19/08
to Quartz.NET
The correct error is "There is already an open DataReader associated
with this Command which must be closed first"


Jason

unread,
Feb 19, 2008, 7:14:36 AM2/19/08
to Quartz.NET
I guess I have found a bug here...

In StdAdoDelegate.cs

line 1682:

while (rs.Read())
{
trigList.Add(
SelectTrigger(conn,
GetString(rs[ColumnTriggerName]), GetString(rs[ColumnTriggerGroup])));
}

====
the "rs" is the datareader which is using conn......
therefore, we should change code

Patch:

public virtual Trigger[]
SelectTriggersForCalendar(ConnectionAndTransactionHolder conn, string
calName)
{
ArrayList trigList = new ArrayList();
StringDictionary triggers = new StringDictionary();

using (IDbCommand cmd = PrepareCommand(conn,
ReplaceTablePrefix(SqlSelectTriggersForCalendar)))
{
AddCommandParameter(cmd, 1, "calendarName", calName);
using (IDataReader rs = cmd.ExecuteReader())
{
while (rs.Read())
{
triggers.Add(GetString(rs[ColumnTriggerName]),
GetString(rs[ColumnTriggerGroup]));
}
}
}

if(triggers.Count > 0)
{
foreach (DictionaryEntry trigger in triggers)
{
trigList.Add(SelectTrigger(conn,
trigger.Key.ToString(), trigger.Value.ToString()));
}
}

return (Trigger[]) trigList.ToArray(typeof (Trigger));
}

Marko Lahma

unread,
Feb 19, 2008, 8:53:31 AM2/19/08
to quar...@googlegroups.com
And thanks Jason also for this, I've created another JIRA issue for
this one: http://jira.opensymphony.com/browse/QRTZNET-93 .

Cheers,

-Marko

Marko Lahma

unread,
Feb 24, 2008, 6:37:59 AM2/24/08
to quar...@googlegroups.com
Now fixed in trunk.

-Marko

Reply all
Reply to author
Forward
0 new messages