Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Start namespace ixSQLServer
- var ixSQLServer = new Object();
- ixSQLServer =
- {
- /**
- * Open a custom connection to SQLServer by id
- * @ConnectId Connection Id
- * @throws an Exception on Error
- */
- openConnection: function (connectId) {
- log.debug("openConnection(");
- if (EM_connections[connectId].initdone == true) {
- return;
- }
- log.debug("Now init JDBC driver");
- var driverName = EM_connections[connectId].driver;
- var dbUrl = EM_connections[connectId].url;
- var strURL = EM_connections[connectId].url;
- var dbUser = EM_connections[connectId].user;
- var dbPassword = EM_connections[connectId].password;
- if (emConnect.decryptAs) {
- dbPassword = emConnect.decryptAs(dbPassword);
- }
- try {
- if (!EM_connections[connectId].classloaded) {
- Class.forName(driverName).newInstance();
- log.debug("Register driver JDBC VENDOR");
- //DriverManager.registerDriver(new JdbcOdbcDriver());
- EM_connections[connectId].classloaded = true;
- }
- log.debug("Get Connection");
- EM_connections[connectId].dbcn = DriverManager.getConnection(dbUrl, dbUser, dbPassword);
- log.debug("Init done.");
- } catch (e) {
- log.debug("ODBC Exception: " + e);
- throw e;
- }
- EM_connections[connectId].initdone = true;
- log.debug(")openConnection");
- },
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- /**
- * Close custom connection
- * @ConnectId Connection Id for the SQLServer Database
- */
- closeConnection: function (connectId) {
- log.debug("closeConnection(");
- if (EM_connections[connectId].initdone) {
- if (EM_connections[connectId].dbcn) {
- try {
- EM_connections[connectId].dbcn.close();
- EM_connections[connectId].initdone = false;
- log.debug("Connection closed: " + connectId);
- } catch (e) {
- log.info("Error closing database " + connectId + ": " + e);
- }
- }
- }
- log.debug(")closeConnection");
- },
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- getOfferData: function (ConnectId, strBarcode) {
- var strSQL;
- var result = null;
- if (log.isDebugEnabled()) log.debug("getOfferData(");
- try {
- strSQL = "SELECT OfferNumber, CustomerId, CustomerName, CustomerAddress, CustomerCountry, CustomerZIP, CustomerCity, DocDateISO, DocDate, AmountExclVAT, AmountInclVAT, VAT, Barcode \
- FROM SOWAER_R2_TEST.dbo.SalesOffer \
- WHERE Barcode = '"+strBarcode+"'";
- result = db.getLine(ConnectId, strSQL);
- }
- catch(e) {
- var error = e;
- log.error("Error getting Offer Data: " + error);
- }
- if (log.isDebugEnabled()) log.debug(")getOfferData");
- return result;
- },
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- getVendorData: function (ConnectId, strVendorNumber, strMandantNumber) {
- var strSQL;
- var result = null;
- if (log.isDebugEnabled()) log.debug("getVendorData(");
- try {
- strSQL = "SELECT [VE_NAME],[VE_STREET],[VE_ZIPCODE],[VE_CITY],[VE_COUNTRY] \
- FROM [DocXtractor_Matching_DB].[DocXtractor].[SFI_VENDOR] \
- WHERE [VE_VENDOR_NO] = '" + strVendorNumber + "' \
- AND [VE_RECIPIENT_NO] = '" + strMandantNumber + "'";
- result = db.getLine(ConnectId, strSQL);
- }
- catch(e) {
- var error = e;
- log.error("Error getting Vendor Data: " + error);
- }
- if (log.isDebugEnabled()) log.debug(")getVendorData");
- return result;
- },
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- }
- // end of namespace ixSQLServer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement