UNPKG

summer-mvc

Version:

Structured, Light, Spring-like Web Application Development Framework

226 lines (142 loc) 4.13 kB
// const config = { // user: 'usrCERND', // password: 'usrIMSI^0730CERND', // server: 'DIOPRDB01', // database: 'front2007' // } // const sql = require( "mssql" ); // var pool = null; // var connection = null; // var query = "select * from ZCCT1010_BACK where EMP_NO = 'i0198101'"; // var query2 = "INSERT INTO TB_TEST (test,id) VALUES ('11','33'. '')"; // function getPool( config ){ // return new Promise( function(resolve, reject){ // sql.connect( config ) // .then( function(_pool){ // resolve( _pool ); // } ) // .catch( function(err){ // reject( err ); // } ); // } ); // } // function getConnection( pool ){ // return new Promise( function(resolve, reject){ // resolve( new sql.Request( pool ) ); // } ); // } // function executeQuery( connection ){ // return new Promise( function(resolve, reject){ // connection.query( query ) // .then( function( result ){ // console.log( result ); // resolve( result ); // } ) // } ); // } // // getPool( config ) // // .then( function(res){ // // console.log( res ); // // getConnection( pool ) // // .then( function( _res){ // // console.log( _res ); // // executeQuery( connection ) // + // // .then( function(__res){ // // console.log( "---------------------------" ); // // console.log( __res ); // // console.log( "---------------------------" ); // // return; // // } ) // // } ) // // } ) // getPool( config ) // .then( function(pool){ // const transaction = pool.transaction(); // transaction.begin( function(err){ // let rolledBack = false; // transaction.on( "rollback", function(aborted){ // rolledBack = true; // } ) // if( err ){ // console.log( "!" ); // console.dir( err ); // } // const _request = transaction.request(); // _request.query( query, function(err, result){ // if (err) { // if (!rolledBack) { // transaction.rollback(err => { // // ... error checks // console.log( "ROLLBACK SUCCEED" ); // console.log( err ); // }) // } // } else { // transaction.commit(err => { // // ... error checks // console.log( result ); // return result; // }) // } // } ) // } ) // } ) // .catch( function(err){ // return err; // } ); // // sql.connect( config ) // // .then( function(pool){ // // pool.request().query( "select * from zcct1010 where emp_no = 'i0198101'" ) // // .then( function(result){ // // console.log( result ); // // } ) // // } ) function testDB(){ return new Promise( function(resolve, reject){ require( "./tools/common/defined.js" ); global.mssqlHandler = require( __mssqlHandler ); mssqlHandler.getPool() .then( function(_pool){ // console.log( _pool ); global.pool = _pool; mssqlHandler.getQueries() .then( function(_queries){ global.queriesXML = _queries; console.dir( queriesXML.queries.query ); mssqlHandler.getConnection( _pool ) .then( function( connection ){ // mssqlHandler.executeQuery( "getZCCT1010", [], connection ) // .then( function(result){ // console.log( result ); // resolve( result ); // } ) // .catch( function(err){ // console.log( err ); // reject( err ); // } ); mssqlHandler.executeQuery( "getZCCT1010", [] ) .then( function(result){ console.log( result ); resolve( result ); } ) .catch( function(err){ console.log( err ); reject( err ); } ); } ) .catch( function(err){ console.log( err ); reject( err ); } ); } ) .catch( function(err){ reject( err ); } ); } ) .catch( function(err){ console.log( err ); } ); } ); } testDB();