mrc logo mrc logo
  • m-Power m-Power
    What is m-Power?
    Overview Demos Build Process Case Studies Specs Pricing Trial
    m-Power Resources
    Overview How-To Videos Webinars & Podcasts White Papers Fact Sheets
  • Solutions Solutions
    What does m-Power build?
    Overview Database Front-Ends Reporting CRM Systems Business Intelligence Dashboards Inventory Management Mobile Apps ERP Enhancements Modernization Spreadsheets to the web MS Access to the web B2B/Web Portals Scheduling Embedded Analytics Web Forms Workflow Data Exploration Budgeting & Forecasting APIs and Web Services Db2 Web Query Alternative
    Solutions by Industry
    Overview Manufacturing Government Foodservice Software Vendors Logistics & Supply Chain Software Consultants Healthcare
  • Services Services
    Development Services Training Mentoring
  • About About
    Overview Partners Press Releases Careers Events Contact Blog
  • Support Support
    Support Home FAQ Documentation Customer Portal Enhancements Updates Roadmap Techblog
Try m-Power

m-Power Manual

Browse:

  • Home
  • External Objects & UDFs
  • Sample External Object (Java) Source Code
Back to Manual

Sample External Object (Java) Source Code

 


package MRCWORKLIB;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;

import com.mrc.dbo.MrcConnection;
/**
 * Delete Order # from MRCWORKLIB.ORDDET
 * 2011-09-22
 * @author RH
 *
 * 2. Define external object
 *
 * Class Name: MRCWORKLIB.DELDETAIL
 * Method Name: run
 * Then define one object parm to pass Order number
 * 3. Use this object in your servlet application
 *
 */
public class DELDETAIL {

        private Logger log = Logger.getLogger(this.getClass());

    /****************************************************
     * Delete from MRCWORKLIB.ORDDET
     ****************************************************/
        public void run(String[] str) {

                if (str.length < 1) {                         log.info("Must pass Order #.");                         return;                 }                 int ordno = 0;                 try {                         ordno = Integer.parseInt(str[0]);                 } catch (Exception e) {                         log.info("Invalid Order # passed.");                         return;                 }                 String sql = "delete from MRCWORKLIB.ORDDET where ORDNUM=" + ordno;                 Connection conn = null;                 try {                         //Get connection configured in m-power/mrcjava/web-inf/classes/spring-config.xml                         conn = MrcConnection.getConnection("as400_remote1");                         Statement stmt = conn.createStatement();                         int deleted = stmt.executeUpdate(sql);                         log.info(deleted + " records deleted.");                         stmt.close();                 } catch (SQLException sqle) {                         log.error("sql = " + sql, sqle);                 } finally {                         try {                                 conn.close();                         } catch (Exception e) {                                 e.printStackTrace();                         }                 }         }         /****************************************************          * Test          ****************************************************/         public static void main(String[] str) {                 DELDETAIL delete = new DELDETAIL();                 String[] str0 = { "2" };                 delete.run(str0);         } }

Created: October 19, 2011 | Modified: December 22, 2011

Search


Browse By Category

Build Process (13)
Starting with m-Power (8)
Retrievals (10)
Reports (15)
Summaries (4)
Maintainers (17)
Graphs (8)
m-Power Data Explorer (4)
General (24)
Calculations (5)
Utilities (9)
m-Power Administration (23)
Security (11)
Freemarker (6)
m-Painter (29)
Form Validation (5)
External Objects & UDFs (12)
Deprecated Documentation (23)
Bootstrap Templates (7)

Popular Tags

Video Bar Graphs m-Painter Report Production Prompt Screens Retrievals Administration Performance Record Selections Parameters Graphs Data Dictionary Freemarker Database Popular Maintainer Reports Advanced Retrieval RPG Getting Started Summaries Email Tomcat Java Graphing Bootstrap Templates External Objects Form Validation SQL Build Process App Properties mrc-Productivity Series Excel Graph Properties Dates Admin Compiling Application Properties DB2 Dropdowns Security Maintainers Calculations

See all tags »

michaels, ross & cole, ltd. (mrc)

Privacy Policy Cookie Policy Cookie Settings Notice at Collection Do Not Sell or Share My Personal Information

mrc (US)

2001 Midwest Road
Suite 310
Oak Brook, IL 60523
630-916-0662

mrc (UK)

Mortlake Business Centre
20 Mortlake High Street
London, SW14 8JN
+44-20-335-59566


© 2024 mrc. All rights reserved.