From 5470f270033e4f1eea70ade90408c3204464aedf Mon Sep 17 00:00:00 2001 From: Rafael Sanchez Bodoque Date: Mon, 2 Aug 2021 13:13:51 +0200 Subject: [PATCH] Use common pool --- sybase/sybaseClient.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sybase/sybaseClient.go b/sybase/sybaseClient.go index 3c50b56..c17fec0 100644 --- a/sybase/sybaseClient.go +++ b/sybase/sybaseClient.go @@ -21,8 +21,12 @@ func NewSyBaseClient(conn driver.Connector, schema string) *SyBaseClient { } } +var db *sql.DB + func (c *SyBaseClient) getDB() *sql.DB { - db := sql.OpenDB(c.conn) + if db == nil { + db = sql.OpenDB(c.conn) + } return db } @@ -37,7 +41,6 @@ func (c *SyBaseClient) Query(sql string) (*sql.Rows, error) { if err := c.moveToSchema(db); err != nil { return nil, err } - defer db.Close() return db.Query(sql) }