Java Code Examples for java.sql.ResultSet#updateTimestamp()

The following examples show how to use java.sql.ResultSet#updateTimestamp() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExportToJdbcPlugin.java    From constellation with Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example 2
Source File: ResultSet2FileSender.java    From iaf with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: UnsupportedUpdateOperationResultSetTest.java    From sharding-jdbc-1.5.1 with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateTimestampForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateTimestamp(1, new Timestamp(0L));
    }
}
 
Example 4
Source File: UnsupportedUpdateOperationResultSetTest.java    From sharding-jdbc-1.5.1 with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateTimestampForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateTimestamp("label", new Timestamp(0L));
    }
}
 
Example 5
Source File: H2Trigger.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void fire(Connection conn, ResultSet oldRow, ResultSet newRow) throws SQLException {
	newRow.updateTimestamp("last_modified", Timestamp.from(Instant.now()));
}
 
Example 6
Source File: TradeSellOrdersDMLDistTxStmt.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 7
Source File: UnsupportedUpdateOperationResultSetTest.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateTimestampForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateTimestamp(1, new Timestamp(0L));
    }
}
 
Example 8
Source File: UnsupportedUpdateOperationResultSetTest.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateTimestampForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateTimestamp("label", new Timestamp(0L));
    }
}
 
Example 9
Source File: TradeSellOrdersDMLDistTxStmt.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
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;
}