Skip to content

Commit c5ef32b

Browse files
committed
Additional output
1 parent 2488a3d commit c5ef32b

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/connection/sqlJob.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,17 @@ export class SQLJob {
5757
const connection = instance.getConnection();
5858
return new Promise((resolve, reject) => {
5959
// 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) {
6266
reject(err);
67+
ServerComponent.writeOutput(err);
68+
}
6369
let outString = ``;
70+
6471
stream.on(`data`, (data: Buffer) => {
6572
outString += String(data);
6673
if (outString.endsWith(`\n`)) {
@@ -76,8 +83,11 @@ export class SQLJob {
7683
}
7784
}
7885
});
86+
7987
resolve(stream);
80-
})
88+
});
89+
90+
console.log(a);
8191
})
8292
}
8393

@@ -101,6 +111,18 @@ export class SQLJob {
101111
async connect(): Promise<ConnectionResult> {
102112
this.channel = await this.getChannel();
103113

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+
104126
this.status = JobStatus.Ready;
105127

106128
const props = Object
@@ -132,13 +154,6 @@ export class SQLJob {
132154
throw new Error(connectResult.error || `Failed to connect to server.`);
133155
}
134156

135-
this.channel.on(`error`, () => {
136-
this.dispose();
137-
})
138-
139-
this.channel.on(`close`, () => {
140-
this.dispose();
141-
})
142157
this.id = connectResult.job;
143158
this.status = JobStatus.Ready;
144159

0 commit comments

Comments
 (0)