admin管理员组文章数量:1025791
I am Using node-mssql Link:
while I am inserting bulk data in mssql table it lost connection
while I am inserting data above 4 rows at a time it will throw an error
import * as SQL from "mssql";
const conn = new sql.ConnectionPool({
user: "XXXXXXXXX",
password: "XXXXXXXXXXX",
server: "XXXXXXXXXXX",
database: "TESTDATA",
options: {
instanceName: "XXX"
},
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
}
});
conn.connect()
var values = [[john,1,4,80],[jenny,null,4,78],[abhi,3,4,null],[ram,4,4,90]]
const table = new sql.Table('CLASS_TABLE');
table.columns.add('NAME', sql.NVarChar(15));
table.columns.add('ROLL', sql.Int);
table.columns.add('CLASS', sql.Int);
table.columns.add('MARKS', sql.Int);
for (let i = 0; i < values.length; i++) {
let row_data = values[i];
if (row_data) {
table.rows.add(row_data[0], row_data[1], row_data[2], row_data[3], row_data[4])
}
}
const request = new sql.Request(conn);
request.bulk(table, (err, result) => {
throw err
});
Error : RequestError: Connection lost - read ECONNRESET
I am Using node-mssql Link: https://www.npmjs./package/mssql
while I am inserting bulk data in mssql table it lost connection
while I am inserting data above 4 rows at a time it will throw an error
import * as SQL from "mssql";
const conn = new sql.ConnectionPool({
user: "XXXXXXXXX",
password: "XXXXXXXXXXX",
server: "XXXXXXXXXXX",
database: "TESTDATA",
options: {
instanceName: "XXX"
},
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
}
});
conn.connect()
var values = [[john,1,4,80],[jenny,null,4,78],[abhi,3,4,null],[ram,4,4,90]]
const table = new sql.Table('CLASS_TABLE');
table.columns.add('NAME', sql.NVarChar(15));
table.columns.add('ROLL', sql.Int);
table.columns.add('CLASS', sql.Int);
table.columns.add('MARKS', sql.Int);
for (let i = 0; i < values.length; i++) {
let row_data = values[i];
if (row_data) {
table.rows.add(row_data[0], row_data[1], row_data[2], row_data[3], row_data[4])
}
}
const request = new sql.Request(conn);
request.bulk(table, (err, result) => {
throw err
});
Error : RequestError: Connection lost - read ECONNRESET
Share Improve this question edited Sep 4, 2019 at 8:58 Sai Jeevan Balla asked Jun 21, 2019 at 12:25 Sai Jeevan BallaSai Jeevan Balla 1453 silver badges10 bronze badges2 Answers
Reset to default 2In your connection options please mention stream :true to insert multiple records.
const conn = new sql.ConnectionPool({
user: "XXXXXXXXX",
password: "XXXXXXXXXXX",
server: "XXXXXXXXXXX",
database: "TESTDATA",
options: {
instanceName: "XXX"
},
stream:true,
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
}
});
I guess there is a parameter which determines the max allowed data at a time
Iam not familiar with mssql,but in MySQL when we want to insert large data at once we will change the parameter max_allowed_packet to a large value
so check if there is a similar parameter and change it
I am Using node-mssql Link:
while I am inserting bulk data in mssql table it lost connection
while I am inserting data above 4 rows at a time it will throw an error
import * as SQL from "mssql";
const conn = new sql.ConnectionPool({
user: "XXXXXXXXX",
password: "XXXXXXXXXXX",
server: "XXXXXXXXXXX",
database: "TESTDATA",
options: {
instanceName: "XXX"
},
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
}
});
conn.connect()
var values = [[john,1,4,80],[jenny,null,4,78],[abhi,3,4,null],[ram,4,4,90]]
const table = new sql.Table('CLASS_TABLE');
table.columns.add('NAME', sql.NVarChar(15));
table.columns.add('ROLL', sql.Int);
table.columns.add('CLASS', sql.Int);
table.columns.add('MARKS', sql.Int);
for (let i = 0; i < values.length; i++) {
let row_data = values[i];
if (row_data) {
table.rows.add(row_data[0], row_data[1], row_data[2], row_data[3], row_data[4])
}
}
const request = new sql.Request(conn);
request.bulk(table, (err, result) => {
throw err
});
Error : RequestError: Connection lost - read ECONNRESET
I am Using node-mssql Link: https://www.npmjs./package/mssql
while I am inserting bulk data in mssql table it lost connection
while I am inserting data above 4 rows at a time it will throw an error
import * as SQL from "mssql";
const conn = new sql.ConnectionPool({
user: "XXXXXXXXX",
password: "XXXXXXXXXXX",
server: "XXXXXXXXXXX",
database: "TESTDATA",
options: {
instanceName: "XXX"
},
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
}
});
conn.connect()
var values = [[john,1,4,80],[jenny,null,4,78],[abhi,3,4,null],[ram,4,4,90]]
const table = new sql.Table('CLASS_TABLE');
table.columns.add('NAME', sql.NVarChar(15));
table.columns.add('ROLL', sql.Int);
table.columns.add('CLASS', sql.Int);
table.columns.add('MARKS', sql.Int);
for (let i = 0; i < values.length; i++) {
let row_data = values[i];
if (row_data) {
table.rows.add(row_data[0], row_data[1], row_data[2], row_data[3], row_data[4])
}
}
const request = new sql.Request(conn);
request.bulk(table, (err, result) => {
throw err
});
Error : RequestError: Connection lost - read ECONNRESET
Share Improve this question edited Sep 4, 2019 at 8:58 Sai Jeevan Balla asked Jun 21, 2019 at 12:25 Sai Jeevan BallaSai Jeevan Balla 1453 silver badges10 bronze badges2 Answers
Reset to default 2In your connection options please mention stream :true to insert multiple records.
const conn = new sql.ConnectionPool({
user: "XXXXXXXXX",
password: "XXXXXXXXXXX",
server: "XXXXXXXXXXX",
database: "TESTDATA",
options: {
instanceName: "XXX"
},
stream:true,
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
}
});
I guess there is a parameter which determines the max allowed data at a time
Iam not familiar with mssql,but in MySQL when we want to insert large data at once we will change the parameter max_allowed_packet to a large value
so check if there is a similar parameter and change it
本文标签: javascriptRequestError Connection lostread ECONNRESET for mssql in nodejsStack Overflow
版权声明:本文标题:javascript - RequestError: Connection lost - read ECONNRESET for mssql in nodejs - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745636176a2160460.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论