Ejemplo n.º 1
0
 protected long getNextSid() throws LoadException {
   try {
     String sql = "SELECT nextval('S_ENZH')";
     Statement stmt = this.conn_.createStatement();
     ResultSet rs = stmt.executeQuery(sql);
     long sid = 0;
     if (rs.next()) sid = rs.getLong(1);
     rs.close();
     stmt.close();
     return sid;
   } catch (SQLException se) {
     throw new LoadException("SQLException occurred: " + se.getMessage());
   }
 }
Ejemplo n.º 2
0
  protected long saveUnit(String en, String zh) throws LoadException {
    if (this.rs_ == null) {
      String sql = "SELECT * FROM T_ENZH WHERE F_SID = 0";
      try {
        Statement stmt =
            this.conn_.createStatement(
                ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
        this.rs_ = stmt.executeQuery(sql);
        Statement stmt1 =
            this.conn_.createStatement(
                ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
        this.rs1_ = stmt1.executeQuery("SELECT * FROM T_ENZHX WHERE F_Word='x'");
        Statement stmt2 =
            this.conn_.createStatement(
                ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
        this.rs2_ = stmt2.executeQuery("SELECT * FROM T_ZHENX WHERE F_Word='x'");
      } catch (SQLException se) {
        throw new LoadException("SQLException occurred: " + se.getMessage());
      }
    }
    if (this.rs_ == null) throw new LoadException("ResultSet not ready! ");

    long sid = getNextSid();
    // System.out.println("SID = "+sid);
    try {
      this.rs_.moveToInsertRow();
      this.rs_.updateLong("F_SID", sid);
      this.rs_.updateString("F_Source", en);
      this.rs_.updateString("F_Target", zh);
      this.rs_.updateString("F_Domain", this.domain_);
      this.rs_.updateInt("F_From", this.from_);
      // this.rs_.updateString("F_Permit", "P");	//default
      // this.rs_.updateInt("F_Owner", 0);	//default
      this.rs_.insertRow();
      return sid;
    } catch (SQLException se) {
      throw new LoadException("SQLException occurred: " + se.getMessage());
    }
  }