public void setDate(int parameterIndex, java.sql.Date inputValue, java.util.Calendar inputCalendar) //throws SQLException { String dateString; /* * Convert string to YYYYMMDD format that dBase needs. */ if (inputValue == (java.sql.Date)null) { setString(parameterIndex, (String)null); } else if (inputValue.toString().trim().length() < 8) { setString(parameterIndex, (String)null); } else { dateString = inputValue.toString().trim(); /* * Convert date string to the standard YYYYMMDD format */ dateString = UtilString.dateValue(dateString); setString(parameterIndex, dateString); } }
public void setDate(int parameterIndex, java.sql.Date inputValue) //throws SQLException { String dateString; /* * Convert string to YYYYMMDD format that dBase needs. */ dateString = UtilString.dateValue(inputValue.toString()); setString(parameterIndex, dateString); }
/* * Update a single column. * * @param column the column name * @param value the String value with which update the column * @see tinySQLTable#UpdateCol * */ public override void UpdateCol(String colName, String value) //throws TinySQLException { String shortColumnName; try { /* * If it's the pseudo column _DELETED, return */ if (colName.equals("_DELETED")) { return; } /* * Retrieve the TsColumn object which corresponds to this column. */ shortColumnName = TinySQLGlobals.getShortName(colName); TsColumn column = (TsColumn)column_info.get(shortColumnName); if (column == null) { throw new TinySQLException("Can't update field=" + colName); } if (Utils.isDateColumn(column.type)) { /* * Convert non-blank dates to the standard YYYYMMDD format. */ if (value.trim().length() > 0) { value = UtilString.dateValue(value); } } /* * Seek the starting offset of the current record, * as indicated by currentRecordNumber */ ftbl.seek(dbfHeader.headerLength + (currentRecordNumber - 1) * dbfHeader.recordLength + column.position); /* * Enforce the correct column length, transform to byte and write to file */ value = Utils.forceToSize(value, column.size, " "); byte[] b = value.getBytes(Utils.encode); ftbl.write(b); dbfHeader.setTimestamp(ftbl); } catch (Exception e) { throw new TinySQLException(e.getMessage()); } }
/* * Create the tinySQLTable object, then insert a row, and update * it with the c and v Vectors */ private void InsertStatement(String statementType, String tableName, java.util.Vector <Object> c, java.util.Vector <Object> v) //throws TinySQLException { String columnName, valueString; int i, columnType, columnSize; double value; insertTable = getTable(tableName); /* * Check that the values supplied are the correct type and length. */ for (i = 0; i < c.size(); i++) { columnName = (String)c.elementAt(i); valueString = (String)v.elementAt(i); if (valueString == (String)null) { continue; } valueString = UtilString.removeQuotes(valueString); valueString = UtilString.replaceAll(valueString, "''", "'"); columnType = insertTable.ColType(columnName); if (Utils.isNumberColumn(columnType)) { try { value = java.lang.Double.parseDouble(valueString); } catch (Exception) { throw new TinySQLException("Insert failed: column " + columnName + " is numeric - found " + valueString); } } else if (Utils.isDateColumn(columnType)) { try { /* * Modify the input to be the standard YYYYMMDD format */ if (valueString.trim().length() > 0) { v.setElementAt(UtilString.dateValue(valueString), i); } } catch (Exception e) { throw new TinySQLException("Insert failed: " + e.getMessage()); } } columnSize = insertTable.ColSize(columnName); if (valueString.length() > columnSize) { throw new TinySQLException("Insert failed: string too long for " + " column " + columnName + " " + java.lang.Integer.toString(valueString.length()) + " > " + java.lang.Integer.toString(columnSize) + "<" + valueString + ">"); } } insertTable.InsertRow(c, v); /* * Close the table file that has just been updated unless this is a * PreparedStatement. In that case an explicit close must be done * on the statement object to close any open files. */ if (!statementType.endsWith("tinySQLPreparedStatement")) { insertTable.close(); } }