Exemplo n.º 1
0
 /** Increment the buffer size for the list. */
 private final void resize() throws SQLException {
   int newsize = data.length << 1;
   if (newsize > 0xFFFFFF) { // see pointerSize
     newsize = 0xFFFFFF;
     if (newsize == data.length) throw SmallSQLException.create(Language.INDEX_TOOMANY_EQUALS);
   }
   byte[] temp = new byte[newsize];
   System.arraycopy(data, 0, temp, 0, data.length);
   data = temp;
 }
Exemplo n.º 2
0
 final void setNeedGeneratedKeys(int autoGeneratedKeys) throws SQLException {
   switch (autoGeneratedKeys) {
     case NO_GENERATED_KEYS:
       break;
     case RETURN_GENERATED_KEYS:
       needGeneratedKeys = true;
       break;
     default:
       throw SmallSQLException.create(
           Language.ARGUMENT_INVALID, String.valueOf(autoGeneratedKeys));
   }
 }
Exemplo n.º 3
0
 public final boolean getMoreResults(int current) throws SQLException {
   switch (current) {
     case CLOSE_ALL_RESULTS:
       // currently there exists only one ResultSet
     case CLOSE_CURRENT_RESULT:
       ResultSet rs = cmd.getResultSet();
       cmd.rs = null;
       if (rs != null) rs.close();
       break;
     case KEEP_CURRENT_RESULT:
       break;
     default:
       throw SmallSQLException.create(Language.FLAGVALUE_INVALID, String.valueOf(current));
   }
   return cmd.getMoreResults();
 }
Exemplo n.º 4
0
 private final void executeImpl(String sql) throws SQLException {
   checkStatement();
   generatedKeys = null;
   try {
     con.log.println(sql);
     SQLParser parser = new SQLParser();
     cmd = parser.parse(con, sql);
     if (maxRows != 0 && (cmd.getMaxRows() == -1 || cmd.getMaxRows() > maxRows))
       cmd.setMaxRows(maxRows);
     cmd.execute(con, this);
   } catch (Exception e) {
     throw SmallSQLException.createFromException(e);
   }
   needGeneratedKeys = false;
   generatedKeyIndexes = null;
   generatedKeyNames = null;
 }
Exemplo n.º 5
0
 void checkStatement() throws SQLException {
   if (isClosed) {
     throw SmallSQLException.create(Language.STMT_IS_CLOSED);
   }
 }
Exemplo n.º 6
0
 public final ResultSet getGeneratedKeys() throws SQLException {
   if (generatedKeys == null) throw SmallSQLException.create(Language.GENER_KEYS_UNREQUIRED);
   return generatedKeys;
 }
Exemplo n.º 7
0
 public final void setCursorName(String name) throws SQLException {
   /** @todo: Implement this java.sql.Statement.setCursorName method */
   throw SmallSQLException.create(Language.UNSUPPORTED_OPERATION, "setCursorName");
 }
Exemplo n.º 8
0
 public final void setMaxRows(int max) throws SQLException {
   if (max < 0) throw SmallSQLException.create(Language.ROWS_WRONG_MAX, String.valueOf(max));
   maxRows = max;
 }
Exemplo n.º 9
0
 /**
  * Create a SQLException that the current function can not convert the specific data type.
  *
  * @param dataType A data type const from SQLTokenizer.
  */
 SQLException createUnspportedConversion(int dataType) {
   Object[] params = {SQLTokenizer.getKeyWord(dataType), SQLTokenizer.getKeyWord(getFunction())};
   return SmallSQLException.create(Language.UNSUPPORTED_CONVERSION_FUNC, params);
 }
Exemplo n.º 10
0
 /**
  * Create a SQLException that the current function does not support the specific data type.
  *
  * @param dataType A data type const from SQLTokenizer.
  */
 SQLException createUnspportedDataType(int dataType) {
   Object[] params = {SQLTokenizer.getKeyWord(dataType), SQLTokenizer.getKeyWord(getFunction())};
   return SmallSQLException.create(Language.UNSUPPORTED_DATATYPE_FUNC, params);
 }
Exemplo n.º 11
0
 void setPrecision(int precision) throws SQLException {
   if (precision < 0)
     throw SmallSQLException.create(
         Language.COL_INVALID_SIZE, new Object[] {new Integer(precision), name});
   this.precision = precision;
 }