⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tinysqlpreparedstatement.java

📁 TinySQL是一个轻量级的纯java数据库引擎
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
   *
   * Get the warning chain associated with this Statement
   * @see java.sql.PreparedStatement#getWarnings
   * @return the chain of warnings
   *
   */
  public final SQLWarning getWarnings() throws SQLException {
    return null;
  }

  /**
   *
   * Clear the warning chain associated with this Statement
   * @see java.sql.PreparedStatement#clearWarnings
   *
   */
  public void clearWarnings() throws SQLException {
  }

  /**
   * 
   * Sets the cursor name for this connection. Presently unsupported.
   *
   */
  public void setCursorName(String unused) throws SQLException {
    throw new SQLException("tinySQL does not support cursors.");
  }

    //--------------------------JDBC 2.0-----------------------------


    /**
     * JDBC 2.0
     *
     * Gives the driver a hint as to the direction in which
         * the rows in a result set
     * will be processed. The hint applies only to result sets created 
     * using this Statement object.  The default value is 
     * ResultSet.FETCH_FORWARD.
     * <p>Note that this method sets the default fetch direction for 
         * result sets generated by this <code>Statement</code> object.
         * Each result set has its own methods for getting and setting
         * its own fetch direction.
     * @param direction the initial direction for processing rows
     * @exception SQLException if a database access error occurs
         * or the given direction
     * is not one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or
     * ResultSet.FETCH_UNKNOWN
     */
    public void setFetchDirection(int direction) throws SQLException {
      throw new SQLException("tinySQL does not support setFetchDirection.");
    }

    /**
     * JDBC 2.0
     *
     * Retrieves the direction for fetching rows from
         * database tables that is the default for result sets
         * generated from this <code>Statement</code> object.
         * If this <code>Statement</code> object has not set
         * a fetch direction by calling the method <code>setFetchDirection</code>,
         * the return value is implementation-specific.
     *
     * @return the default fetch direction for result sets generated
         *          from this <code>Statement</code> object
     * @exception SQLException if a database access error occurs
     */
    public int getFetchDirection() throws SQLException {
      throw new SQLException("tinySQL does not support getFetchDirection.");
    }

    /**
     * JDBC 2.0
     *
     * Gives the JDBC driver a hint as to the number of rows that should 
     * be fetched from the database when more rows are needed.  The number 
     * of rows specified affects only result sets created using this 
     * statement. If the value specified is zero, then the hint is ignored.
     * The default value is zero.
     *
     * @param rows the number of rows to fetch
     * @exception SQLException if a database access error occurs, or the
     * condition 0 <= rows <= this.getMaxRows() is not satisfied.
     */
    public void setFetchSize(int rows) throws SQLException {
      if ((rows <= 0) || (rows >= this.getMaxRows ()))
    		  throw new SQLException ("Condition 0 <= rows <= this.getMaxRows() is not satisfied");
    
      fetchsize = rows;  
    }

    /**
     * JDBC 2.0
     *
     * Retrieves the number of result set rows that is the default 
         * fetch size for result sets
         * generated from this <code>Statement</code> object.
         * If this <code>Statement</code> object has not set
         * a fetch size by calling the method <code>setFetchSize</code>,
         * the return value is implementation-specific.
     * @return the default fetch size for result sets generated
         *          from this <code>Statement</code> object
     * @exception SQLException if a database access error occurs
     */
    public int getFetchSize() throws SQLException {
      return fetchsize;
    }

    /**
     * JDBC 2.0
     *
     * Retrieves the result set concurrency.
     */
    public int getResultSetConcurrency() throws SQLException {
      throw new SQLException("tinySQL does not support ResultSet concurrency.");
    }

    /**
     * JDBC 2.0
     *
     * Determine the result set type.
     */
    public int getResultSetType()  throws SQLException {
      throw new SQLException("tinySQL does not support getResultSetType.");
    }

    /**
     * JDBC 2.0
     *
     * Adds a SQL command to the current batch of commmands for the statement.
     * This method is optional.
     *
     * @param sql typically this is a static SQL INSERT or UPDATE statement
     * @exception SQLException if a database access error occurs, or the
     * driver does not support batch statements
     */
    public void addBatch() throws SQLException {
      throw new SQLException("tinySQL does not support addBatch.");
    }
    public void addBatch( String sql ) throws SQLException {
      throw new SQLException("tinySQL does not support addBatch.");
    }

    /**
     * JDBC 2.0
     *
     * Makes the set of commands in the current batch empty.
     * This method is optional.
     *
     * @exception SQLException if a database access error occurs or the
     * driver does not support batch statements
     */
    public void clearBatch() throws SQLException {
      throw new SQLException("tinySQL does not support clearBatch.");
    }

    /**
     * JDBC 2.0
     * 
     * Submits a batch of commands to the database for execution.
     * This method is optional.
     *
     * @return an array of update counts containing one element for each
     * command in the batch.  The array is ordered according 
     * to the order in which commands were inserted into the batch.
     * @exception SQLException if a database access error occurs or the
     * driver does not support batch statements
     */
    public int[] executeBatch() throws SQLException {
      throw new SQLException("tinySQL does not support executeBatch.");
    }

    /**
     * JDBC 2.0
     * 
     * Returns the <code>Connection</code> object
         * that produced this <code>Statement</code> object.
         * @return the connection that produced this statement
     * @exception SQLException if a database access error occurs
     */
    public Connection getConnection()  throws SQLException
    {
      return connection;
    }
/*
 *  Set methods for the prepared statement.
 */
    public void setBoolean(int parameterIndex,boolean inputValue)
       throws SQLException
    {
       if ( inputValue ) setString(parameterIndex,"TRUE");
       else setString(parameterIndex,"FALSE");
    }
    public void setInt(int parameterIndex,int inputValue)
       throws SQLException
    {
       setString(parameterIndex,Integer.toString(inputValue));
    }
    public void setDouble(int parameterIndex,double inputValue)
       throws SQLException
    {
       setString(parameterIndex,Double.toString(inputValue));
    }
    public void setBigDecimal(int parameterIndex,BigDecimal inputValue)
       throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    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);
    }
    public void setTime(int parameterIndex,java.sql.Time inputValue,
       java.util.Calendar inputCalendar) throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setTime(int parameterIndex,java.sql.Time inputValue)
       throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setTimestamp(int parameterIndex,java.sql.Timestamp inputValue,
       java.util.Calendar inputCalendar ) throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setTimestamp(int parameterIndex,java.sql.Timestamp inputValue)
       throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setAsciiStream(int parameterIndex,
       java.io.InputStream inputValue,int streamLength) throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setUnicodeStream(int parameterIndex,
       java.io.InputStream inputValue,int streamLength) throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setBinaryStream(int parameterIndex,
       java.io.InputStream inputValue,int streamLength) throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setCharacterStream(int parameterIndex,
       java.io.Reader inputValue,int streamLength) throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setRef(int parameterIndex,java.sql.Ref inputValue)
       throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setBlob(int parameterIndex,java.sql.Blob inputValue)
       throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setArray(int parameterIndex,java.sql.Array inputValue)
       throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setClob(int parameterIndex,java.sql.Clob inputValue)
       throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setByte(int parameterIndex,byte inputValue)
       throws SQLException
    {
       setString(parameterIndex,Byte.toString(inputValue));
    }
    public void setBytes(int parameterIndex,byte[] inputValue)
       throws SQLException
    {
       setString(parameterIndex,Byte.toString(inputValue[0]));
    }
    public void setShort(int parameterIndex,short inputValue)
       throws SQLException
    {
       setString(parameterIndex,Short.toString(inputValue));
    }
    public void setFloat(int parameterIndex,float inputValue)
       throws SQLException
    {
       setString(parameterIndex,Float.toString(inputValue));
    }
    public void setLong(int parameterIndex,long inputValue)
       throws SQLException
    {
       setString(parameterIndex,Long.toString(inputValue));
    }
    public void setObject(int parameterIndex,Object inputValue)
       throws SQLException
    {
       setObject(parameterIndex,inputValue,0,0);
    }
    public void setObject(int parameterIndex,Object inputValue,
       int targetSQLType) throws SQLException
    {
       setObject(parameterIndex,inputValue,targetSQLType,0);
    }
    public void setObject(int parameterIndex,Object inputValue,
       int targetSQLType, int scale) throws SQLException
    {
       setString(parameterIndex,inputValue.toString());
    }
    public void setNull(int parameterIndex,int sqlType)
       throws SQLException
    {
       setNull(parameterIndex,sqlType,(String)null);
    }
    public void setNull(int parameterIndex,int sqlType,String sqlTypeName)
       throws SQLException
    {
       if ( parameterIndex > substitute.size() )
          throw new SQLException("Parameter index " + parameterIndex 
          + invalidIndex);
       substitute.setElementAt((String)null,parameterIndex-1);
    }
    public void setString( int parameterIndex, String setString)
       throws SQLException
    {
       if ( parameterIndex > substitute.size() )
          throw new SQLException("Parameter index " + parameterIndex 
          + invalidIndex);
       substitute.setElementAt(setString,parameterIndex-1);
    }
    public void clearParameters() throws SQLException
    {
       substitute.removeAllElements();
    }
/*
 *  Update the actions based upon the contents of the substitute Vector.
 *  Only INSERT and UPDATE commands are supported at this time.
 */
    public void updateActions(Vector inputActions) throws SQLException
    {
       Vector values,originalValues;
       Hashtable action;
       String actionType,valueString;
       int i,j,subCount;
       if ( actions == (Vector)null )
          actions = inputActions;
       if ( actions == (Vector)null ) return;
       for ( i = 0; i < actions.size(); i++ )
       {
          action = (Hashtable)actions.elementAt(i); 
          actionType = (String)action.get("TYPE");
          if ( actionType.equals("INSERT") | actionType.equals("UPDATE") )
          {
/*
 *           Look for the original values (with the ? for parameters).
 */
             originalValues = (Vector)action.get("ORIGINAL_VALUES");
             values = (Vector)action.get("VALUES");
             if ( originalValues == (Vector)null ) 
             {
                originalValues = (Vector)values.clone();
                action.put("ORIGINAL_VALUES",originalValues);
             }
             subCount = 0;
             for ( j = 0; j < originalValues.size(); j++ )
             {
                valueString = (String)originalValues.elementAt(j);
                if ( valueString.equals("?") )
                {
                   if ( subCount > substitute.size() - 1 )
                      throw new SQLException("Substitution index " + subCount
                      + " not between 0 and " 
                      + Integer.toString(substitute.size() - 1));
                   values.setElementAt(substitute.elementAt(subCount),j);
                   subCount++;
                }
             }
          }
       }
    }
    public void addTable(tinySQLTable inputTable)
    {
       int i;
       tinySQLTable nextTable;
       for ( i = 0; i < tableList.size(); i++ )
       {
          nextTable = (tinySQLTable)tableList.elementAt(i);
          if ( nextTable.table.equals(inputTable.table) ) return;
       }
       tableList.addElement(inputTable);
    }
      
     
    public Vector getActions()
    {
       return actions;
    }
    public ResultSetMetaData getMetaData()
    {
       return (ResultSetMetaData)null;
    }
       
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -