Skip to Content mrc logo mrc logo
  • 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
  • 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 & Web Services Db2 Web Query Alternative
    Solutions by Industry
    Overview Manufacturing Government Foodservice Software Vendors Logistics & Supply Chain Software Consultants Healthcare
  • Development Services Training Mentoring
  • Overview Partners Press Releases Careers Events Contact Blog
  • 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

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

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


© mrc. All rights reserved.