@@ -113,14 +113,19 @@ function parameterizeQuery(query, params, callback) {
113113 } ) ;
114114}
115115
116+ function isSafeToUseJavaBridge ( sql ) {
117+ var lowerSQL = sql . toLowerCase ( ) ;
118+ return lowerSQL . indexOf ( "insert" ) === - 1 && lowerSQL . indexOf ( "update" ) === - 1 && lowerSQL . indexOf ( "delete" ) === - 1 ;
119+ }
120+
116121function executePreparedStatement ( api , sql , parameters , connection , next , db ) {
117122 async . waterfall ( [
118123 function ( cb ) {
119124 parameterizeQuery ( sql , parameters , cb ) ;
120125 } , function ( parametrizedQuery , cb ) {
121126 sql = parametrizedQuery ;
122127
123- if ( api . helper . readTransaction ) {
128+ if ( isSafeToUseJavaBridge ( sql ) && api . helper . readTransaction ) {
124129 api . log ( "Calling Java Bridge" , "debug" ) ;
125130
126131 api . log ( sql , "debug" ) ;
@@ -304,8 +309,13 @@ exports.dataAccess = function (api, next) {
304309 return ;
305310 }
306311
307- if ( ! api . helper . readTransaction ) {
312+ sql = queries [ queryName ] . sql ;
313+
314+ if ( ! isSafeToUseJavaBridge ( sql ) || ! api . helper . readTransaction ) {
308315 connection = connectionMap [ queries [ queryName ] . db ] ;
316+ api . log ( "######### MD #########" , "info" ) ;
317+ api . log ( JSON . stringify ( connectionMap ) , "info" ) ;
318+ api . log ( queryName , "info" ) ;
309319 error = helper . checkObject ( connection , "connection" ) ;
310320 }
311321
@@ -314,7 +324,6 @@ exports.dataAccess = function (api, next) {
314324 return ;
315325 }
316326
317- sql = queries [ queryName ] . sql ;
318327 if ( ! sql ) {
319328 api . log ( 'Unregistered query ' + queryName + ' is asked for.' , 'error' ) ;
320329 next ( 'The query for name ' + queryName + ' is not registered' ) ;
@@ -354,7 +363,7 @@ exports.dataAccess = function (api, next) {
354363 return ;
355364 }
356365
357- if ( ! api . helper . readTransaction ) {
366+ if ( ! isSafeToUseJavaBridge ( sql ) || ! api . helper . readTransaction ) {
358367 connection = connectionMap [ dbName ] ;
359368 error = helper . checkObject ( connection , "connection" ) ;
360369 }
0 commit comments