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) {
110
110
return ;
111
111
}
112
112
113
+ let connection ;
113
114
try {
114
115
// Checkout a connection from the default pool
115
- let connection = await oracledb . getConnection ( ) ;
116
+ connection = await oracledb . getConnection ( ) ;
116
117
117
118
const result = await connection . execute (
118
119
`SELECT employee_id, first_name, last_name
@@ -121,14 +122,20 @@ async function handleRequest(request, response) {
121
122
[ deptid ] // bind variable value
122
123
) ;
123
124
124
- // Release the connection back to the connection pool
125
- await connection . close ( ) ;
126
-
127
125
displayResults ( response , result , deptid ) ;
126
+
128
127
} catch ( err ) {
129
128
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
+ }
130
138
}
131
-
132
139
htmlFooter ( response ) ;
133
140
}
134
141
You can’t perform that action at this time.
0 commit comments