File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -110,9 +110,10 @@ async function handleRequest(request, response) {
110110 return ;
111111 }
112112
113+ let connection ;
113114 try {
114115 // Checkout a connection from the default pool
115- let connection = await oracledb . getConnection ( ) ;
116+ connection = await oracledb . getConnection ( ) ;
116117
117118 const result = await connection . execute (
118119 `SELECT employee_id, first_name, last_name
@@ -121,14 +122,20 @@ async function handleRequest(request, response) {
121122 [ deptid ] // bind variable value
122123 ) ;
123124
124- // Release the connection back to the connection pool
125- await connection . close ( ) ;
126-
127125 displayResults ( response , result , deptid ) ;
126+
128127 } catch ( err ) {
129128 handleError ( response , "handleRequest() error" , err ) ;
129+ } finally {
130+ if ( connection ) {
131+ try {
132+ // Release the connection back to the connection pool
133+ await connection . close ( ) ;
134+ } catch ( err ) {
135+ console . error ( err ) ;
136+ }
137+ }
130138 }
131-
132139 htmlFooter ( response ) ;
133140}
134141
You can’t perform that action at this time.
0 commit comments