@@ -34,8 +34,11 @@ var fs = require("fs");
3434var async = require ( "async" ) ;
3535var java = require ( 'java' ) ;
3636var Jdbc = require ( 'informix-wrapper' ) ;
37+ var req = require ( 'request' ) ;
3738var helper ;
3839
40+ var javaReadBridge = process . env . JAVA_READ_BRIDGE || "http://localhost:5555/bridge" ;
41+
3942/**
4043 * Regex for sql paramters e.g @param_name@
4144 */
@@ -110,7 +113,7 @@ function parameterizeQuery(query, params, callback) {
110113 } ) ;
111114}
112115
113- function executePreparedStatement ( api , sql , parameters , connection , next ) {
116+ function executePreparedStatement ( api , sql , parameters , connection , next , db ) {
114117 async . waterfall ( [
115118 function ( cb ) {
116119 parameterizeQuery ( sql , parameters , cb ) ;
@@ -119,8 +122,19 @@ function executePreparedStatement(api, sql, parameters, connection, next) {
119122
120123 if ( api . helper . readTransaction ) {
121124 api . log ( "CALLING SANTTOSH'S MAGIC" ) ;
122- api . log ( new Buffer ( sql ) . toString ( 'base64' ) ) ;
123- cb ( null , [ ] ) ; // necessary?
125+
126+ var body = {
127+ "sql" : new Buffer ( sql ) . toString ( 'base64' ) ,
128+ "db" : db
129+ } ;
130+
131+ api . log ( body ) ;
132+
133+ req ( { url : javaReadBridge , body : body , json : true } , function ( response ) {
134+ api . log ( response ) ;
135+ } ) ;
136+
137+ cb ( null , [ ] ) ;
124138 } else {
125139 api . log ( "Database connected" , 'debug' ) ;
126140 // the connection might have been closed due to other errors, so this check must be done
@@ -294,7 +308,7 @@ exports.dataAccess = function (api, next) {
294308 return ;
295309 }
296310
297- executePreparedStatement ( api , sql , parameters , connection , next ) ;
311+ executePreparedStatement ( api , sql , parameters , connection , next , queries [ queryName ] . db ) ;
298312 } ,
299313
300314 /**
@@ -337,7 +351,7 @@ exports.dataAccess = function (api, next) {
337351 return ;
338352 }
339353
340- executePreparedStatement ( api , sql , parameters , connection , next ) ;
354+ executePreparedStatement ( api , sql , parameters , connection , next , dbName ) ;
341355 }
342356 } ;
343357 next ( ) ;
0 commit comments