@@ -34,8 +34,11 @@ var fs = require("fs");
34
34
var async = require ( "async" ) ;
35
35
var java = require ( 'java' ) ;
36
36
var Jdbc = require ( 'informix-wrapper' ) ;
37
+ var req = require ( 'request' ) ;
37
38
var helper ;
38
39
40
+ var javaReadBridge = process . env . JAVA_READ_BRIDGE || "http://localhost:5555/bridge" ;
41
+
39
42
/**
40
43
* Regex for sql paramters e.g @param_name@
41
44
*/
@@ -110,7 +113,7 @@ function parameterizeQuery(query, params, callback) {
110
113
} ) ;
111
114
}
112
115
113
- function executePreparedStatement ( api , sql , parameters , connection , next ) {
116
+ function executePreparedStatement ( api , sql , parameters , connection , next , db ) {
114
117
async . waterfall ( [
115
118
function ( cb ) {
116
119
parameterizeQuery ( sql , parameters , cb ) ;
@@ -119,8 +122,19 @@ function executePreparedStatement(api, sql, parameters, connection, next) {
119
122
120
123
if ( api . helper . readTransaction ) {
121
124
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 , [ ] ) ;
124
138
} else {
125
139
api . log ( "Database connected" , 'debug' ) ;
126
140
// 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) {
294
308
return ;
295
309
}
296
310
297
- executePreparedStatement ( api , sql , parameters , connection , next ) ;
311
+ executePreparedStatement ( api , sql , parameters , connection , next , queries [ queryName ] . db ) ;
298
312
} ,
299
313
300
314
/**
@@ -337,7 +351,7 @@ exports.dataAccess = function (api, next) {
337
351
return ;
338
352
}
339
353
340
- executePreparedStatement ( api , sql , parameters , connection , next ) ;
354
+ executePreparedStatement ( api , sql , parameters , connection , next , dbName ) ;
341
355
}
342
356
} ;
343
357
next ( ) ;
0 commit comments