.Net PostgreSQL 连接字符串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/464131/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:38:26  来源:igfitidea点击:

.Net PostgreSQL Connection String

.netdatabasepostgresqlconnection-string

提问by Ash

I am using PostgreSQL in a project I am working on, and one of the queries is timing out. I need to increase the timeout on the database connection, but since I am using my DAO through a complex wrapper to Active Record and NHibernate, I am not able to adjust the timeout of the command object - so I am hoping you can change the timeout through the connection string.

我在我正在处理的项目中使用 PostgreSQL,其中一个查询超时。我需要增加数据库连接的超时时间,但由于我通过一个复杂的包装器使用我的 DAO 到 Active Record 和 NHibernate,我无法调整命令对象的超时 - 所以我希望你可以更改超时通过连接字符串。

Any ideas?

有任何想法吗?

采纳答案by EdgarVerona

Try this one:

试试这个:

Provider=PostgreSQL OLE DB Provider;Data Source=myServerAddress;location=myDataBase;User ID=myUsername;password=myPassword;timeout=1000;

Provider=PostgreSQL OLE DB Provider;Data Source=myServerAddress;location=myDataBase;User ID=myUsername;password=myPassword;timeout=1000;

Just replace the obvious parts (myUsername, myServerAddress, etc...) with your stuff.

只需用您的东西替换明显的部分(myUsername、myServerAddress 等...)。

Also, for your reference, this site will give you connection string templates for pretty much any database on earth for pretty much any way you need to use it:

此外,为了您的参考,该站点将为您提供地球上几乎任何数据库的连接字符串模板,您需要以任何方式使用它:

http://www.connectionstrings.com

http://www.connectionstrings.com

回答by Michael Buen

Npgsql-native connection string:

Npgsql -本机连接字符串:

Server=127.0.0.1;Port=5432;Userid=u;Password=p;Protocol=3;SSL=false;Pooling=false;MinPoolSize=1;MaxPoolSize=20;Timeout=15;SslMode=Disable;Database=test"

回答by Ash

Found it: CommandTimeout=20;Timeout=15;

找到了:CommandTimeout=20;Timeout=15;

回答by RedWolves

Have you tried to optimize the query? Optimizing is the best choice over increasing timeouts.

您是否尝试过优化查询?优化是增加超时的最佳选择。