diff --git a/pkg/telemetryservice/sql/mysql/mysql.go b/pkg/telemetryservice/sql/mysql/mysql.go index 0f4b47f50..cbdefacd0 100644 --- a/pkg/telemetryservice/sql/mysql/mysql.go +++ b/pkg/telemetryservice/sql/mysql/mysql.go @@ -35,6 +35,8 @@ func (db *DBHelper) SendToDB(ctx context.Context, deviceName string, rawData []b return err } + defer db.DB.Close() + err = db.InsertDataToDB(ctx, deviceName, rawData) if err != nil { logger.Errorf("Error to Insert rawData to DB, errror: %v", err.Error()) diff --git a/pkg/telemetryservice/sql/sqlserver/sqlserver.go b/pkg/telemetryservice/sql/sqlserver/sqlserver.go index c661798b8..2f2f4e791 100644 --- a/pkg/telemetryservice/sql/sqlserver/sqlserver.go +++ b/pkg/telemetryservice/sql/sqlserver/sqlserver.go @@ -35,6 +35,8 @@ func (db *DBHelper) SendToDB(ctx context.Context, deviceName string, rawData []b return err } + defer db.DB.Close() + err = db.InsertDataToDB(ctx, deviceName, rawData) if err != nil { logger.Errorf("Error to Insert rawData to DB, errror: %v", err.Error()) diff --git a/pkg/telemetryservice/sql/tdengine/tdengine.go b/pkg/telemetryservice/sql/tdengine/tdengine.go index 70acfc4c4..e603f0b20 100644 --- a/pkg/telemetryservice/sql/tdengine/tdengine.go +++ b/pkg/telemetryservice/sql/tdengine/tdengine.go @@ -28,6 +28,8 @@ func (db *DBHelper) SendToDB(ctx context.Context, deviceName string, rawData []b return err } + defer db.DB.Close() + err = db.InsertDataToDB(ctx, deviceName, rawData) if err != nil { logger.Errorf("Error to Insert rawData to DB, errror: %v", err.Error())