.net 应用程序的 oracle 连接超时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4453659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.net application's oracle connection timing out
提问by kacalapy
i have the code below trying to do a bulk copy from oracle to SQL server 2005 and it keeps timing out. how can i extend the oracle connection timeout? it seems i can not from what i read on the web.
我有下面的代码试图从 oracle 到 SQL Server 2005 进行批量复制,但它一直超时。如何延长 oracle 连接超时?看来我不能从我在网上读到的内容。
OracleConnection source = new OracleConnection(GetOracleConnectionString());
source.Open();
SqlConnection dest = new SqlConnection(GetSQLConnectionString() );
dest.Open();
OracleCommand sourceCommand = new OracleCommand(@"select * from table");
using (OracleDataReader dr = sourceCommand.ExecuteReader())
{
using (SqlBulkCopy s = new SqlBulkCopy(dest))
{
s.DestinationTableName = "Defects";
s.NotifyAfter = 100;
s.SqlRowsCopied += new SqlRowsCopiedEventHandler(s_SqlRowsCopied);
s.WriteToServer(dr);
s.Close();
}
}
source.Close();
dest.Close();
here is my oracle connection string:
这是我的 oracle 连接字符串:
return "User Id=USER;Password=pass;Data Source=(DESCRIPTION=" +
"(ADDRESS=(PROTOCOL=TCP)(HOST=14.12.7.2)(PORT=1139))" +
"(CONNECT_DATA=(SID=QCTRP1)));";
采纳答案by Jordan Parmer
In your connection string, there is a 'Connection Lifetime' and 'Connection Timeout' parameter. You can set it accordingly. See herefor the full reference.
在您的连接字符串中,有一个“Connection Lifetime”和“Connection Timeout”参数。您可以相应地进行设置。有关完整参考,请参见此处。
BTW, I know you didn't ask this, but have you considered an ETL tool for migrating your DB records (e.g. Informatica, FME, etc.)? While your approach is valid, it isn't going to be very performant since you are hydrating all of the records from one DB to the client and then serializing them to another DB. For small bulk sets, this isn't a big issue, but if you were processing hundreds of thousands of rows, you might want to consider an official ETL tool.
顺便说一句,我知道您没有问这个问题,但是您是否考虑过使用 ETL 工具来迁移您的数据库记录(例如 Informatica、FME 等)?虽然您的方法是有效的,但它的性能不会很好,因为您将所有记录从一个 DB 到客户端,然后将它们序列化到另一个 DB。对于小型批量集,这不是什么大问题,但如果您要处理数十万行,则可能需要考虑使用官方 ETL 工具。
回答by boa7-2011
You can set s.BulkCopyTimeout option
您可以设置 s.BulkCopyTimeout 选项