Estou com problema para fazer um insert no banco externo,
Estou usando esta regra
"function createDataset(fields, constraints, sortFields) { limparFields(fields);
var dataset = DatasetBuilder.newDataset(); dataset.addColumn("nome");
var dataSource = "/jdbc/orcamento"; var ic = new javax.naming.InitialContext(); var ds = ic.lookup(dataSource);
var myQuery = "insert into SL1 ("+ "L1_XLBTKRG," "L1_XHRTKRG," ") values ("+ "'"+fields[0]+"',"+ "'"+fields[1]+"'"+ ")";
log.info("===myQuery: "+myQuery);
try { var conn = ds.getConnection(); var stmt = conn.createStatement();
var rs = stmt.executeQuery(myQuery);
} catch (e) { log.error("ERRO==============> " + e.message);
dataset.addRow([e.message]); } finally { if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); }
dataset.addRow(["Ok"]); }
return dataset; }
function limparFields(fields){ for(var i = 0; i < fields.length; i++){ fields[i] = fields[i].replace("'", "").replace("%", "").replace("#", "").trim(); }
return fields;
Alguem poderia me ajudar.