public void setNull(int parameterIndex, int sqlType, String sqlTypeName) //throws SQLException { if (parameterIndex > substitute.size()) { throw new java.sql.SQLException("Parameter index " + parameterIndex + invalidIndex); } substitute.setElementAt((String)null, parameterIndex - 1); }
/** * * Return a tinySQLTable object, given a table name. * * @param tableName * @see tinySQL#getTable * */ internal override TinySQLTable getTable(String tableName) //throws tinySQLException { int i, tableIndex; TinySQLTable nextTable; tableIndex = java.lang.Integer.MIN_VALUE; if (TinySQLGlobals.DEBUG) { java.lang.SystemJ.outJ.println("Trying to create table" + " object for " + tableName); } for (i = 0; i < tableList.size(); i++) { nextTable = (TinySQLTable)tableList.elementAt(i); if (nextTable.table.equals(tableName)) { if (nextTable.isOpen()) { if (TinySQLGlobals.DEBUG) { java.lang.SystemJ.outJ.println("Found in cache " + nextTable.toString()); } return(nextTable); } tableIndex = i; break; } } if (tableIndex == java.lang.Integer.MIN_VALUE) { tableList.addElement(new DBFFileTable(dataDir, tableName)); nextTable = (TinySQLTable)tableList.lastElement(); if (TinySQLGlobals.DEBUG) { java.lang.SystemJ.outJ.println("Add to cache " + nextTable.toString()); } return((TinySQLTable)tableList.lastElement()); } else { tableList.setElementAt(new DBFFileTable(dataDir, tableName), tableIndex); nextTable = (TinySQLTable)tableList.elementAt(tableIndex); if (TinySQLGlobals.DEBUG) { java.lang.SystemJ.outJ.println("Update in cache " + nextTable.toString()); } return((TinySQLTable)tableList.elementAt(tableIndex)); } }
/* * 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(); } }
public void updateRow(TsRow inputRow, int rowIndex) { rows.setElementAt(inputRow, rowIndex); }