Questions tagged [dbconnection]
230 questions
219
votes
5 answers
Right query to get the current number of connections in a PostgreSQL DB
Which of the following two is more accurate?
select numbackends from pg_stat_database;
select count(*) from pg_stat_activity;

Murali VP
- 6,198
- 4
- 28
- 36
118
votes
5 answers
nodejs mysql Error: Connection lost The server closed the connection
when I use node mysql, an error is appear between 12:00 to 2:00 that the TCP connection is shutdown by the server. This is the full message:
Error: Connection lost: The server closed the connection.
at Protocol.end…

jackieLin
- 1,237
- 2
- 9
- 9
73
votes
5 answers
Is java.sql.Connection thread safe?
To rephrase the question: should I avoid sharing instances of classes which implement java.sql.Connection between different threads?

Boris Pavlović
- 63,078
- 28
- 122
- 148
27
votes
7 answers
Docker MySQL connection DBeaver
I just finished following this Docker tutorial on youtube:
https://www.youtube.com/watch?v=SXY0MLHP3hA&lc=Ugzp3vKtSOp0rn2lYyd4AaABAg
I was able to create a couple of Docker containers for PHP and MySQL. The file structure is as…

John Beasley
- 2,577
- 9
- 43
- 89
23
votes
4 answers
C# Retrieving correct DbConnection object by connection string
I have a connection string being passed to a function, and I need to create a DbConnection based object (i.e. SQLConnection, OracleConnection, OLEDbConnection etc) based on this string.
Is there any inbuilt functionality to do this, or any 3rd…

johnc
- 39,385
- 37
- 101
- 139
16
votes
5 answers
How can I hide my password in my C# Connection string?
I have the following connection string:
Data Source=Paul-HP\MYDB;Initial Catalog=MyMSDBSQL;Persist Security Info=True;User ID=sa;Password=password
(.net webservice)
This can obviously be viewed simply by opening up the app.config file and looking…

IAmGroot
- 13,760
- 18
- 84
- 154
10
votes
3 answers
ASP.NET: How to create a connection from a web.config ConnectionString?
How do you construct a DbConnection based on a provider name?
Sample provider names
System.Data.SqlClient
System.Data.OleDb
System.Data.Odbc
FirebirdSql.Data.FirebirdClient
i have connection strings stored in my IIS server's web.config…

Ian Boyd
- 246,734
- 253
- 869
- 1,219
8
votes
5 answers
Is there any need to close a DbConnection if a using clause is used?
Possible Duplicate:
Will a using block close a database connection?
Is db.Close() unnecessary in the following?
using (DbConnection db = GetDbConnection())
{
// do data-access stuff
// ...
db.Close();
}

CJ7
- 22,579
- 65
- 193
- 321
7
votes
3 answers
DbConnection without Db using in-memory DataSet (or similar) as source
I'm trying to unit test a few .NET classes that (for good design reasons) require DbConnections to do their work. For these tests, I have certain data in memory to give as input to these classes.
That in-memory data could be easily expressed as a…

Jerry Federspiel
- 1,504
- 10
- 14
7
votes
4 answers
Is using a singleton for the connection a good idea in ASP.NET website
I'm currently using a singleton on my web application so that there is always only one connection to the database.
I want to know if it's a good idea because right now I'm having trouble with that error:
Timeout expired. The timeout period elapsed…

Jean-François Côté
- 4,200
- 11
- 52
- 88
6
votes
1 answer
Does DbContext holds an opened connection during its life-cycle?
The question is pretty clear. Does DbContext hold an open connection during its life-cycle? What about EF core?

amiry jd
- 27,021
- 30
- 116
- 215
6
votes
1 answer
HikariCP auto reconnect
I use jpa+hibernate+hikariCP. Today I got connection closed error. I setted connectionTimeout and ideleTimeout properties(hikari). If in meantime use does not do any operition hikari close the pool connections auto. So that I got closed connection…

sancho
- 598
- 2
- 8
- 22
6
votes
2 answers
Laravel Multi Database Connection Join table
Datebase 1 = db1
Database 2 = db2
I have two databases connection, I wanted to run a eloquent or DB which joining connection1 and connection 2 table(db1.users and db2.users), and check connection1 id = connection 2 or not.
can someone guide me how…

php_dvp
- 133
- 1
- 4
- 14
6
votes
2 answers
How to fix dbWriteTable error "unable to find an inherited method for function 'dbWriterTable' for signature...?"
I want to insert data in MySQL from a dataframe in R. I managed to connect without problems from R to MySQL using dbConnect, however when I try to insert my data using dbWriteTable I keep getting the error
unable to find an inherited method for…

antonioACR1
- 1,303
- 2
- 15
- 28
6
votes
1 answer
How to connect to ORACLE DB without oracle client or tnsname
Is there any way to connect to Oracle DB without installing oracle client or using tnsname ? The application needs to be deployed on client machine ,hence want it to be INDEPENDENT.

jen123
- 61
- 1
- 1
- 4