@@ -57,10 +57,17 @@ export class SQLJob {
57
57
const connection = instance . getConnection ( ) ;
58
58
return new Promise ( ( resolve , reject ) => {
59
59
// Setting QIBM_JAVA_STDIO_CONVERT and QIBM_PASE_DESCRIPTOR_STDIO to make sure all PASE and Java converters are off
60
- connection . client . connection . exec ( `QIBM_JAVA_STDIO_CONVERT=N QIBM_PASE_DESCRIPTOR_STDIO=B exec ` + ServerComponent . getInitCommand ( ) , { } , ( err : any , stream : any , options : { encoding : `binary`} ) => {
61
- if ( err )
60
+ const startingCommand = `QIBM_JAVA_STDIO_CONVERT=N QIBM_PASE_DESCRIPTOR_STDIO=B exec ` + ServerComponent . getInitCommand ( ) ;
61
+
62
+ ServerComponent . writeOutput ( startingCommand ) ;
63
+
64
+ const a = connection . client . connection . exec ( startingCommand , { } , ( err : any , stream : any , options : { encoding : `binary`} ) => {
65
+ if ( err ) {
62
66
reject ( err ) ;
67
+ ServerComponent . writeOutput ( err ) ;
68
+ }
63
69
let outString = `` ;
70
+
64
71
stream . on ( `data` , ( data : Buffer ) => {
65
72
outString += String ( data ) ;
66
73
if ( outString . endsWith ( `\n` ) ) {
@@ -76,8 +83,11 @@ export class SQLJob {
76
83
}
77
84
}
78
85
} ) ;
86
+
79
87
resolve ( stream ) ;
80
- } )
88
+ } ) ;
89
+
90
+ console . log ( a ) ;
81
91
} )
82
92
}
83
93
@@ -101,6 +111,18 @@ export class SQLJob {
101
111
async connect ( ) : Promise < ConnectionResult > {
102
112
this . channel = await this . getChannel ( ) ;
103
113
114
+ this . channel . on ( `error` , ( ) => {
115
+ this . dispose ( ) ;
116
+ } )
117
+
118
+ this . channel . on ( `close` , ( code : number ) => {
119
+ this . dispose ( ) ;
120
+
121
+ if ( code !== 0 ) {
122
+ throw new Error ( `Ended with ${ code } ` ) ;
123
+ }
124
+ } )
125
+
104
126
this . status = JobStatus . Ready ;
105
127
106
128
const props = Object
@@ -132,13 +154,6 @@ export class SQLJob {
132
154
throw new Error ( connectResult . error || `Failed to connect to server.` ) ;
133
155
}
134
156
135
- this . channel . on ( `error` , ( ) => {
136
- this . dispose ( ) ;
137
- } )
138
-
139
- this . channel . on ( `close` , ( ) => {
140
- this . dispose ( ) ;
141
- } )
142
157
this . id = connectResult . job ;
143
158
this . status = JobStatus . Ready ;
144
159
0 commit comments