Initial successfull connecction callback for connecton pooling (DOCS update)
See original GitHub issueHi
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'example.org',
user : 'bob',
password : 'secret'
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
with the above code for connections creation we can print successfully connected message initially to indicate the the db is connected
How to do the same when we create a new pool and want to know that the server successfully connected before executing any queries …
var mysql = require('mysql');
var pool = mysql.createPool(...);
how to print the initial connected to db message with this…
If there is a way please add it to docs, it will be very useful indicate the successful db connection.
Thank You !
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
17 Tuning Data Source Connection Pools - Oracle Help Center
This chapter provides information on how to properly tune the connection pool attributes in JDBC data sources in your WebLogic Server 12.1.3 domain...
Read more >psycopg_pool – Connection pool implementations
The NullConnectionPool is a ConnectionPool subclass which doesn't create connections preemptively and doesn't keep unused connections in its state. See Null ...
Read more >Connecting and disconnecting (Concepts) - Prisma
This page explains how database connections are handled with Prisma Client and how to manually connect and disconnect your database.
Read more >Connecting to Oracle Database - cx_Oracle's documentation!
A connection pool is created by calling SessionPool() . This is generally called during application initialization. The initial pool size and ...
Read more >SQL Server Connection Pooling - ADO.NET - Microsoft Learn
When a connection is first opened, a connection pool is created based on an exact matching algorithm that associates the pool with the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You could execute a query, or even just call getConnection and then release it back if you want. Usually checking that on start is a bit of an antipattern, though, as it can stop connecting right at any point after your app started.
The pool will emit a connection event when a new connection is made within the pool. Creating the pool won’t create a connection until you ask it for a connection.