java.sql.ResultSet#updateTimestamp ( )源码实例Demo

下面列出了java.sql.ResultSet#updateTimestamp ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: constellation   文件: ExportToJdbcPlugin.java
private static void updateResultSetParam(final GraphReadMethods rg, final ResultSet rs, final String label, final Attribute attr, final int id) throws SQLException {
    switch (attr.getAttributeType()) {
        case "boolean":
            rs.updateBoolean(label, rg.getBooleanValue(attr.getId(), id));
            break;
        case "date":
            final long date = rg.getLongValue(attr.getId(), id);
            if (date != Long.MIN_VALUE) {
                rs.updateDate(label, new Date(date));
            }
            break;
        case "datetime":
            final long timestamp = rg.getLongValue(attr.getId(), id);
            if (timestamp != Long.MIN_VALUE) {
                rs.updateTimestamp(label, new Timestamp(timestamp));
            }
            break;
        case "integer":
            rs.updateInt(label, rg.getIntValue(attr.getId(), id));
            break;
        case "float":
            rs.updateFloat(label, rg.getFloatValue(attr.getId(), id));
            break;
        case "time":
            final long time = rg.getLongValue(attr.getId(), id);
            if (time != Long.MIN_VALUE) {
                rs.updateTime(label, new Time(time));
            }
            break;
        default:
            final String s = rg.getStringValue(attr.getId(), id);
            if (s != null) {
                rs.updateString(label, s);
            }
            break;
    }
}
 
源代码2 项目: iaf   文件: ResultSet2FileSender.java
private void processResultSet (ResultSet resultset, FileOutputStream fos, int counter) throws SQLException, IOException {
	String rec_str = resultset.getString(1);
	if (log.isDebugEnabled()) {
		log.debug("iteration [" + counter + "] item [" + rec_str + "]");
	} 
	if ("timestamp".equalsIgnoreCase(getStatusFieldType())) {
		//TODO: statusFieldType is nu altijd een timestamp (dit moeten ook andere types kunnen zijn)
		resultset.updateTimestamp(2 , new Timestamp((new Date()).getTime()));
		resultset.updateRow();
	}
	if (rec_str!=null) {
		fos.write(rec_str.getBytes());
	}
	fos.write(eolArray);
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateTimestampForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateTimestamp(1, new Timestamp(0L));
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateTimestampForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateTimestamp("label", new Timestamp(0L));
    }
}
 
源代码5 项目: phoebus   文件: H2Trigger.java
@Override
public void fire(Connection conn, ResultSet oldRow, ResultSet newRow) throws SQLException {
	newRow.updateTimestamp("last_modified", Timestamp.from(Instant.now()));
}
 
protected int updateTableUsingURS(ResultSet rs, int qty, String status, 
    Timestamp orderTime, int oid, int whichUpdate, boolean[] success) 
    throws SQLException {
  
  int rowCount = 1; 
  
  String txid =  "TXID:" + (Integer)SQLDistTxTest.curTxId.get() + " ";
     
  switch (whichUpdate) {
  case 0: 
    //"update  status = ?        
    Log.getLogWriter().info(txid + "updating tarde.sellorders table using URS with STATUS: " + status  + 
        "where OID:" + oid + " QUERY: " + "update  status = ? where oid = ?");
    //select for update of column (status) has checked already 
    //whether updating on partition column
    rs.updateString("STATUS", status);    
    rs.updateRow();

    break;
  case 1: 
    //"update trade.sellorders set qty = ?,  status = ? where where oid = ?  ",
    Log.getLogWriter().info(txid + "updating trade.sellorders table using URS with QTY:" + qty + ", " +
        "STATUS:" + status + " where OID:" + oid + " QUERY: " + "update trade.sellorders set qty = ?,  status = ? where where oid = ?  ");
    //select for update of column (status and qty) has checked already 
    //whether updating on partition column
    rs.updateInt("QTY", qty);
    rs.updateString("STATUS", status);
    rs.updateRow();
    break;
  case 2: 
    //"update trade.sellorders set order_time = ? where where oid = ? ",
    Log.getLogWriter().info(txid + "updating trade.sellorders table using URS with ORDERTIME:"
        + orderTime + " where OID:" + oid + " QUERY: " + "update trade.sellorders set order_time = ? where where oid = ? ");
    try {
      rs.updateTimestamp("ORDER_TIME", orderTime);
      rs.updateRow();
    } catch (SQLException se) {
      SQLHelper.printSQLException(se);
      if (se.getSQLState().equals("0A000") && 
         partitionKeys.contains("order_time")) {
        rowCount = 0;
        success[0] = false;
        return rowCount;
      } else throw se;
    }      
    break;
  default:
   throw new TestException ("Wrong updatable resultset used here");
  }
  success[0] = true;
  return rowCount;
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateTimestampForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateTimestamp(1, new Timestamp(0L));
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateTimestampForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateTimestamp("label", new Timestamp(0L));
    }
}
 
protected int updateTableUsingURS(ResultSet rs, int qty, String status, 
    Timestamp orderTime, int oid, int whichUpdate, boolean[] success) 
    throws SQLException {
  
  int rowCount = 1; 
  
  String txid =  "TXID:" + (Integer)SQLDistTxTest.curTxId.get() + " ";
     
  switch (whichUpdate) {
  case 0: 
    //"update  status = ?        
    Log.getLogWriter().info(txid + "updating tarde.sellorders table using URS with STATUS: " + status  + 
        "where OID:" + oid + " QUERY: " + "update  status = ? where oid = ?");
    //select for update of column (status) has checked already 
    //whether updating on partition column
    rs.updateString("STATUS", status);    
    rs.updateRow();

    break;
  case 1: 
    //"update trade.sellorders set qty = ?,  status = ? where where oid = ?  ",
    Log.getLogWriter().info(txid + "updating trade.sellorders table using URS with QTY:" + qty + ", " +
        "STATUS:" + status + " where OID:" + oid + " QUERY: " + "update trade.sellorders set qty = ?,  status = ? where where oid = ?  ");
    //select for update of column (status and qty) has checked already 
    //whether updating on partition column
    rs.updateInt("QTY", qty);
    rs.updateString("STATUS", status);
    rs.updateRow();
    break;
  case 2: 
    //"update trade.sellorders set order_time = ? where where oid = ? ",
    Log.getLogWriter().info(txid + "updating trade.sellorders table using URS with ORDERTIME:"
        + orderTime + " where OID:" + oid + " QUERY: " + "update trade.sellorders set order_time = ? where where oid = ? ");
    try {
      rs.updateTimestamp("ORDER_TIME", orderTime);
      rs.updateRow();
    } catch (SQLException se) {
      SQLHelper.printSQLException(se);
      if (se.getSQLState().equals("0A000") && 
         partitionKeys.contains("order_time")) {
        rowCount = 0;
        success[0] = false;
        return rowCount;
      } else throw se;
    }      
    break;
  default:
   throw new TestException ("Wrong updatable resultset used here");
  }
  success[0] = true;
  return rowCount;
}