Package com.exedosoft.plat.bo

Examples of com.exedosoft.plat.bo.DODataSource


  }

  public Connection getConnection() {

    DODataSource dss = DODataSource.parseConfigHelper("/ds_ldap.xml",
        "ds_ladp");
    java.sql.Connection conn = null;
    try {
      Class.forName(dss.getDriverClass());
      conn = DriverManager.getConnection(dss.getDriverUrl(), dss
          .getUserName(), dss.getPassword());
    } catch (Exception e) {
      e.printStackTrace();
    }
    return conn;
  }
View Full Code Here


    return true;
  }

  private void createTable(String createTableSql) {
    // ///更新另外一个库
    DODataSource dss = DOGlobals.getInstance()
        .getSessoinContext().getTenancyValues()
        .getDataDDS();
    Connection con = dss.getConnection();
    try {

      PreparedStatement pstmt = con
          .prepareStatement(createTableSql);
      pstmt.executeUpdate();
View Full Code Here

  private static final long serialVersionUID = 1L;

  public String excute() {

    DOBO bo = DOBO.getDOBOByName("do_datasource");
    DODataSource dss = DODataSource.getDataSourceByL10n(bo
        .getCorrInstance().getValue("l10n"));
   
    String fileName = null;
   
    URL url = DOGlobals.class.getResource("/globals.xml");
    String fullFilePath = url.getPath();
    String prefix = fullFilePath.substring(0, fullFilePath.toLowerCase()
        .indexOf("web-inf"));
    if("mysql".equalsIgnoreCase(dss.getDialect())){
      fileName = prefix + "/exedo/initsql/mysql.sql";
    }else if ("sqlserver".equalsIgnoreCase(dss.getDialect())){
      fileName = prefix + "/exedo/initsql/sqlserver2000.sql";
    }
    else if ("oracle".equalsIgnoreCase(dss.getDialect())){
      fileName = prefix + "/exedo/initsql/oracle.sql";
    }else if ("gae".equalsIgnoreCase(dss.getDialect())){
      fileName = prefix + "/exedo/initsql/gae.sql";
    }
    else if ("db2".equalsIgnoreCase(dss.getDialect())){
      fileName = prefix + "/exedo/initsql/db2.sql";
    }
    else if ("h2".equalsIgnoreCase(dss.getDialect())){
      fileName = prefix + "/exedo/initsql/h2.sql";
    }
    else if ("hsqldb".equalsIgnoreCase(dss.getDialect())){
      fileName = prefix + "/exedo/initsql/hsqldb.sql";
    }
    else{
      this.setEchoValue(I18n.instance().get("现在只支持mysql、oracle、sqlserver、db2、hsqldb、h2和gae等数据库初始化!"));
      return NO_FORWARD;
    }

    Connection con = null;
    try {
      con = dss.getConnection();
      DatabaseMetaData meta = con.getMetaData();
      String[] tblTypes = new String[] { "TABLE" };
      String schema = null;
      if (dss.isOracle()) {
        if(dss.getUserName()!=null){
          schema = dss.getUserName().trim().toUpperCase();
        }
      }
      ResultSet rs = meta.getTables(null, schema, null, tblTypes);
      while (rs.next()) {
        String tableName = rs.getString("TABLE_NAME").toLowerCase();
View Full Code Here

   */
  private static final long serialVersionUID = 1L;

  public String excute() {

    DODataSource dss = null;

    if ("true".equals(DOGlobals.getValue("multi.tenancy"))) {
      dss = DOGlobals.getInstance().getSessoinContext()
          .getTenancyValues().getDataDDS();
    } else {// 单租户情况

      DOBO bo = DOBO.getDOBOByName("do_datasource");
      dss = DODataSource.getDataSourceByL10n(bo.getCorrInstance()
          .getValue("l10n"));
    }

    // if(dss.getDriverClass().equals("org.hsqldb.jdbcDriver") &&
    // dss.getDriverUrl().indexOf("jdbc:hsqldb") == -1){
    // String path =
    // DODataSource.class.getResource("/globals.xml").getPath();
    // path = path.substring(0, path.toLowerCase().indexOf("classes"));
    // StringBuilder driverUrl =
    // new
    // StringBuilder("jdbc:hsqldb:file:").append(path).append("db/").append(dss.getDriverUrl());
    //
    // dss.setDriverUrl(driverUrl.toString());
    // }

    List list = new ArrayList();
    Connection con = null;
    try {
      con = dss.getConnection();
      DatabaseMetaData meta = con.getMetaData();
      String[] tblTypes = new String[] { "TABLE" };

      String schema = null;
      if (dss.isOracle()) {
        schema = dss.getUserName().trim().toUpperCase();
      }
      ResultSet rs = meta.getTables(null, schema, null, tblTypes);
      while (rs.next()) {
        String tableName = rs.getString("TABLE_NAME");
        // ////////////增强更新功能
View Full Code Here

    System.out.println("Create table Sql::" + sb);



    DODataSource dss = null;
    ///多租户情况`
   
    if ("true".equals(DOGlobals.getValue("multi.tenancy"))) {
      dss = DOGlobals.getInstance().getSessoinContext()
          .getTenancyValues().getDataDDS();
    } else {//单租户情况
      DOBO bo = DOBO.getDOBOByName("do_datasource");
      dss = DODataSource.getDataSourceByL10n(bo
          .getCorrInstance().getValue("l10n"));
    }
   
   

    List list = new ArrayList();
    Connection con = null;
    try {
      con = dss.getConnection();
      PreparedStatement pstmt = con.prepareStatement(sb.toString());
      pstmt.executeUpdate();
      pstmt.close();
    } catch (SQLException ex) {
      this.setEchoValue(ex.getMessage());
View Full Code Here

  private int getIDHelper(String codeItemID, String sql, StringBuffer sqlUpdate) {
    Connection con = null;
    PreparedStatement stmt = null;
    DOBO bo = DOBO.getDOBOByName("do_authorization");
    DODataSource dss =  bo.getDataBase();
    try {
      // query


      con = dss.getContextConnection();

      stmt = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE,
          ResultSet.CONCUR_READ_ONLY);
      int retId = 1;

      stmt.setString(1, codeItemID);
      ResultSet rs = stmt.executeQuery();

      if (rs.next()) {
        retId = rs.getInt("max_sequence") + 1;
      }
      // stmt.close();
      //
      // //update
      stmt = con.prepareStatement(sqlUpdate.toString());
      stmt.setString(1, codeItemID);
      stmt.execute();
      return retId;

    } catch (SQLException ex) {
      try {
        con.rollback();
      } catch (SQLException e) {

      }
      ex.printStackTrace();
      return -1;

    } finally {// Close Connection
      try {
        if (stmt != null) {
          stmt.close();
        }
        dss.ifCloseConnection(con);
      } catch (Exception ex1) {
        ex1.printStackTrace();
      }
    }
  }
View Full Code Here

        .append("?,?,?,?,?,?)");

    Connection con = null;
    PreparedStatement stmt = null;
    DOBO bo = DOBO.getDOBOByName("DO_CODE_MAXSEQUENCE");
    DODataSource dss =  bo.getDataBase();

    try {

      con = dss.getContextConnection();

      // //////////////insert
      Date curDate = new Date(System.currentTimeMillis());
      stmt = con.prepareStatement(insertSql.toString());
      stmt.setString(1, UUIDHex.getInstance().generate());
      stmt.setString(2, codeItemID);
      stmt.setString(3, aDeptCode);
      stmt.setInt(4, aYear);
      stmt.setInt(5, aTrashID);
      stmt.setDate(6, curDate);
      stmt.execute();

    } catch (SQLException ex) {
      try {
        con.rollback();
      } catch (SQLException e) {

      }
      ex.printStackTrace();

    } finally {// Close Connection
      try {
        if (stmt != null) {
          stmt.close();
        }
        dss.ifCloseConnection(con);
      } catch (Exception ex1) {
        ex1.printStackTrace();
      }
    }
View Full Code Here

    Connection con = null;
    PreparedStatement stmt = null;
    int retId = -1;// //////////返回的值
    DOBO bo = DOBO.getDOBOByName("DO_CODE_MAXSEQUENCE");
    DODataSource dss =  bo.getDataBase();
    try {

      con = dss.getContextConnection();
      // query
      stmt = con.prepareStatement(selectSql);
      stmt.setString(1, codeItemID);
      stmt.setString(2, aDeptCode);
      stmt.setInt(3, aYear);
      ResultSet rs = stmt.executeQuery();

      if (rs.next()) {
        retId = rs.getInt("TRASH_CODE");
        // update
        stmt = con.prepareStatement(deleteSql.toString());
        stmt.setString(1, codeItemID);
        stmt.setString(2, aDeptCode);
        stmt.setInt(3, aYear);
        stmt.execute();
      }

      return retId;

    } catch (SQLException ex) {
      try {
        con.rollback();
      } catch (SQLException e) {

      }
      ex.printStackTrace();
      return 0;
    } finally {// Close Connection
      try {
        if (stmt != null) {
          stmt.close();
        }
        dss.ifCloseConnection(con);
      } catch (Exception ex1) {
        ex1.printStackTrace();
      }
    }
  }
View Full Code Here

    Connection con = null;
    PreparedStatement stmt = null;
    int retId = 1;// //////////返回的值

    DOBO bo = DOBO.getDOBOByName("do_authorization");
    DODataSource dss =  bo.getDataBase();

    try {
      // query
      con = dss.getContextConnection();

      // query
      stmt = con.prepareStatement(selectSql);
      stmt.setString(1, codeItemID);
      stmt.setString(2, aIndiID);
      ResultSet rs = stmt.executeQuery();

      if (rs.next()) {
        retId = rs.getInt("max_sequence") + 1;
        // update
        stmt = con.prepareStatement(updateSql.toString());
        stmt.setString(1, codeItemID);
        stmt.setString(2, aIndiID);
        stmt.execute();
      } else {
        // //////////////insert
        stmt = con.prepareStatement(insertSql.toString());
        stmt.setString(1, UUIDHex.getInstance().generate());
        stmt.setString(2, aIndiID);
        stmt.setString(3, codeItemID);
        stmt.setString(4, aIndiID);
        stmt.setInt(5, 0);
        stmt.setLong(6, retId);
        stmt.execute();
      }

      return retId;

    } catch (SQLException ex) {
      try {
        con.rollback();
      } catch (SQLException e) {

      }
      ex.printStackTrace();
      return 0;
    } finally {// Close Connection
      try {
        if (stmt != null) {
          stmt.close();
        }
        dss.ifCloseConnection(con);
      } catch (Exception ex1) {
        ex1.printStackTrace();
      }
    }
  }
View Full Code Here

    Connection con = null;
    PreparedStatement stmt = null;
    int retId = 1;// //////////返回的值
    DOBO bo = DOBO.getDOBOByName("do_authorization");
    DODataSource dss =  bo.getDataBase();
    try {


      con = dss.getContextConnection();
      // query
      stmt = con.prepareStatement(selectSql);
      stmt.setString(1, codeItemID);
      stmt.setString(2, aDeptCode);
      stmt.setInt(3, aYear);
      ResultSet rs = stmt.executeQuery();

      if (rs.next()) {
        retId = rs.getInt("max_sequence") + 1;
        // update
        stmt = con.prepareStatement(updateSql.toString());
        stmt.setString(1, codeItemID);
        stmt.setString(2, aDeptCode);
        stmt.setInt(3, aYear);
        stmt.execute();
      } else {
        // //////////////insert
        stmt = con.prepareStatement(insertSql.toString());
        stmt.setString(1, UUIDHex.getInstance().generate());
        stmt.setString(2, aDeptCode);
        stmt.setString(3, codeItemID);
        stmt.setString(4, aDeptCode);
        stmt.setInt(5, aYear);
        stmt.setLong(6, retId);
        stmt.execute();
      }

      return retId;

    } catch (SQLException ex) {
      try {
        con.rollback();
      } catch (SQLException e) {

      }
      ex.printStackTrace();
      return -1;

    } finally {// Close Connection
      try {
        if (stmt != null) {
          stmt.close();
        }
        dss.ifCloseConnection(con);
      } catch (Exception ex1) {
        ex1.printStackTrace();
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.exedosoft.plat.bo.DODataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.