如果具有 OracleDependency,则 OracleCommand 执行会阻塞
我有以下代码:
OracleConnection conn = new OracleConnection(connString);
OracleCommand command = new OracleCommand("select * from testtable", conn);
conn.Open();
OracleDependency.Port = 2010;
OracleDependency dependency = new OracleDependency(command);
command.AddRowid = true;
command.Notification.IsNotifiedOnce = false;
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
command.CommandTimeout = 1000;
DataTable t = new DataTable();
OracleDataAdapter adapter = new OracleDataAdapter(command);
adapter.Fill(t);
conn.Close();
这是一个非常简单的代码,它使用 Oracle 通知服务接收有关特定表更改的通知。
我的问题是,当我调用 adapter.Fill(t);
时,执行会被阻塞。如果没有附加依赖项,则该命令将在实例中执行,因此它不是数据库或数据。我可以通过查询表 user_change_notification_regs
看到注册数据库的回调,并且还打开了指定的端口(2010):
net8://(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST='myIp')(PORT=2010)))?PR=0
我束手无策,没有什么可以尝试的。
I have the following code:
OracleConnection conn = new OracleConnection(connString);
OracleCommand command = new OracleCommand("select * from testtable", conn);
conn.Open();
OracleDependency.Port = 2010;
OracleDependency dependency = new OracleDependency(command);
command.AddRowid = true;
command.Notification.IsNotifiedOnce = false;
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
command.CommandTimeout = 1000;
DataTable t = new DataTable();
OracleDataAdapter adapter = new OracleDataAdapter(command);
adapter.Fill(t);
conn.Close();
This is a very straightforward code that uses Oracle Notification Service to receive notifications about particular table changes.
My problem is that when I call adapter.Fill(t);
the execution simply blocks. The command executes in an instance if there is no dependency attached to it so it's not the database or the data. I can see the call back registering with the database by querying the table user_change_notification_regs
and have also opened the port specified (2010):
net8://(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST='myIp')(PORT=2010)))?PR=0
I am at wits end and rand out of things to try.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我尝试将端口号设置为我的计算机上已使用的端口时,我看到在类似情况下引发了异常。当我注释掉设置端口号后,它就运行良好,所以也许你可以尝试一下?并检查“netstat -na”以了解已使用的端口。
我看到的异常是:
令人困惑的事情(至少对我来说)是,异常不是在设置端口时引发的,而是在稍后对其执行第一个查询时引发的。
I have seen an exception raised in a similar situation when I've tried to set the port number to a port already used on my machine. As soon as I commented out setting the port number it ran fine, so perhaps you could try that? And check "netstat -na" for used ports.
The exception I saw was:
The confusing thing (at least for me) was the exception is raised not when the port is set, but later when the first query was executed against it.