示例#1
0
  public long getNextValue(String seqfunctionname, String sequence, Connection con, String dbname)
      throws SQLException {
    long curValue = 0;
    PreparedDBUtil dbutil = new PreparedDBUtil();
    try {
      //			if()
      String sql = "select " + sequence + ".nextval from dual";
      dbutil.preparedSelect(dbname, sql);
      dbutil.executePrepared(con);
      if (dbutil.size() <= 0) {
        //				System.out.println("select " + this.generator + ".nextval from dual");
        throw new SQLException(
            "[select "
                + sequence
                + ".nextval from dual] from ["
                + dbname
                + "] failed:retrun records is 0.");
      }
      curValue = dbutil.getInt(0, 0);

      return curValue;

    } catch (SQLException e) {
      throw e;
    }
  }
示例#2
0
  /** 大字段的读取 */
  @Test
  public void testBlobRead() {
    PreparedDBUtil dbUtil = new PreparedDBUtil();
    try {
      // 查询大字段内容并且将大字段存放到文件中
      dbUtil.preparedSelect("select id,blobname from test");
      dbUtil.executePrepared();

      for (int i = 0; i < dbUtil.size(); i++) {

        dbUtil.getFile(i, "blobname", new java.io.File("e:/dominspector.rar")); // 将blob字段的值转换为文件
        //				Blob blob = dbUtil.getBlob(i, "blobname");//获取blob字段的值到blob变量中。
      }

    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {

    }
  }
示例#3
0
  /** clob字段的读取 */
  @Test
  public void testClobRead() {
    PreparedDBUtil dbUtil = new PreparedDBUtil();
    try {
      // 查询大字段内容并且将大字段存放到文件中
      dbUtil.preparedSelect("select id,clobname from test");
      dbUtil.executePrepared();

      for (int i = 0; i < dbUtil.size(); i++) {

        dbUtil.getFile(i, "clobname", new java.io.File("d:/route" + i + ".txt")); // 读取clob字段到文件中
        //				String clobvalue = dbUtil.getString(i, "clobname");//获取clob字段到字符串变量中
        //				Clob clob = dbUtil.getClob(i, "clobname");//获取clob字段值到clob类型变量中
      }

    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      dbUtil = null;
    }
  }