zoukankan      html  css  js  c++  java
  • MYOB Developer Jave 创建连接

        代码: 
    Here is the code for a test application I use. The main difference that 
    you must turn of Auto Commit and then pass the commit manually. However
    you may still have to refer to the MYOBPlog.txt file for details of
    errors.

    import java.sql.*;

    public class Main
    {
    static Connection con;
    static Statement St;
    static Driver driver;

    public static void main(String[] args)
    {
    try
    {
    con = null;
    St=null;

    driver = DriverManager.getDriver("jdbc:odbc:AU12");

    //---- DSN ----
    con = DriverManager.getConnection("jdbc:odbc:AU12");

    //----ADO ----
    /*
    String url="jdbc:odbc:Driver={MYOHK0901}; TYPE=MYOB; UID=Administrator; KEY=C:\\Plus13.hk_English\\861020904720.key; " +
    "DATABASE=C:\\Plus13.hk_English\\CT Solutions Limited.myo;HOST_EXE_PATH=C:\\Plus13.hk_English\\MYOBP.exe; " +
    "NETWORK_PROTOCOL=TCPIP; DRIVER_COMPLETION=DRIVER_NOPROMPT; " +
    "ACCESS_TYPE=READ_WRITE;SUPPRESS_WARNINGS=TRUE;" ;
    con =DriverManager.getConnection(url);
    */
    */

    con.setAutoCommit(false);

    St= con.createStatement();

    for( SQLWarning warn = con.getWarnings(); warn != null; warn =
    warn.getNextWarning())
    {
    System.out.println( "SQL Warning:" );
    System.out.println( "State : " + warn.getSQLState() );
    System.out.println( "Message: " + warn.getMessage() );
    System.out.println( "Error : " + warn.getErrorCode() );
    }

    System.out.println("Inserted = "+St.executeUpdate("INSERT INTO
    Import_Items (ItemNumber, QuantityBreak1, PriceLevelFQtyBreak1) VALUES
    ('101', 0, 234.48)" ));

    con.commit();

    St.close();

    if(con!=null)
    {
    con.close();
    }
    }
    catch (Exception ex)
    {
    try
    {
    System.out.println(ex.getMessage());
    ex.printStackTrace();
    if (St!=null)
    {
    St.close();
    St=null;
    }
    if(con!=null)
    {
    con.close();
    con=null;
    }
    }
    catch (Exception ext)
    {
    System.out.println("2222-"+ext.getMessage());
    }
    }
    }
    }
  • 相关阅读:
    m个苹果放入n个篮子
    C++ sort函数用法 C中的qsort
    C常见机试题
    二维数组作为函数参数的几种方法
    远程调用相关技术
    反射 与 序列化
    MFC 三种消息
    【2019.09.13】中秋快乐!来点福大猫咪色图ヽ(=^・ω・^=)丿
    【2019.09.11】用交互式思维导图展示学期规划(软件工程实践2019第二次作业)
    【2019.09.07】审视自我~(软件工程实践2019第一次作业)
  • 原文地址:https://www.cnblogs.com/kentyshang/p/1532978.html
Copyright © 2011-2022 走看看