Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

Any ideas?

share|improve this question
add comment (requires an account with 50 reputation)

4 Answers

up vote 2 down vote accepted

Try this one:

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.

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

share|improve this answer
add comment (requires an account with 50 reputation)

Npgsql-native connection string:

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"
share|improve this answer
add comment (requires an account with 50 reputation)

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

share|improve this answer
I second this, explain analyse is your friend. Look for slow sequential scans and a poor join order, etc. – Dana the Sane Jan 21 '09 at 5:10
add comment (requires an account with 50 reputation)

Found it: CommandTimeout=20;Timeout=15;

share|improve this answer
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.