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

📄 i18npreparedstatement.java

📁 数据仓库工具
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * Calling the method <code>close</code> on a <code>Statement</code>
     * object that is already closed has no effect.
     * <P>
     * <B>Note:</B> A <code>Statement</code> object is automatically closed
     * when it is garbage collected. When a <code>Statement</code> object is
     * closed, its current <code>ResultSet</code> object, if one exists, is
     * also closed.
     *
     * @exception SQLException if a database access error occurs
     */
    public void close() throws SQLException {
      // close all result sets
      for(Enumeration i = resultSets.elements(); i.hasMoreElements(); ) {
        I18nResultSet resultSet = (I18nResultSet) i.nextElement();
        resultSet.close();
      }
     
    }

    /**
     *Description of the Method
     *
     * @exception  SQLException  Description of Exception
     * @since
     */
    public void cancel() throws SQLException
    {
        throw new SQLException("Not Supported !");
    }


    /**
     *Description of the Method
     *
     * @exception  SQLException  Description of Exception
     * @since
     */
    public void clearWarnings() throws SQLException
    {
        throw new SQLException("Not Supported !");
    }


    /**
     *Description of the Method
     *
     * @param  sql               Description of Parameter
     * @return                   Description of the Returned Value
     * @exception  SQLException  Description of Exception
     * @since
     */
    public boolean execute(String sql) throws SQLException
  {
    I18nSqlParser parser = new I18nSqlParser();
    if( binaryStreamParameters.size() != 0 )
          parser.setBinaryStreamList( binaryStreamParameters );
    this.sql = sql;
    try
    {
      parser.parse(this);
    }
    catch (Exception e)
    {
      throw new SQLException("Syntax Error. " + e.getMessage());
    }
      if(parser.sqlType.equals(I18nSqlParser.SELECT))
              throw new SQLException("Not supported SELECT statement - use executeQuery method");
      else if (parser.sqlType.equals(I18nSqlParser.INSERT))
              executeUpdate(sql);
       else if (parser.sqlType.equals(I18nSqlParser.CREATE_TABLE)) {
             String fileName = connection.getPath() + parser.getTableName() + connection.getExtension();
            File checkFile = new File(fileName);

            if (checkFile.exists())
            {
              throw new SQLException("Data file '" + fileName + "'already exists  !");
            }
           
            try
            {
							checkFile.createNewFile();
            
            }
            catch (Exception e)
            {
              throw new SQLException("Error reading data file. Message was: " + e);
            }
        }
        return true;

  }

  /**
   * Set String as parameter in sql statement.
   * @param parameterIndex
   * @param value
   * @throws SQLException
   */
  public void setString(int parameterIndex, String value) throws SQLException {
    if( value == null ) {
      I18nDriver.log("value = null object");
      parameters.set(parameterIndex - 1, value);
    } else {
      value = Utils.replaceAll(value, "'", I18nSqlParser.QUOTE_ESCAPE);
	  	I18nDriver.log("value = " + value);
      parameters.set(parameterIndex - 1, "'" + value + "'");
    }
  }


  /**
   *
   * @param parameterIndex
   * @param value
   * @throws SQLException
   */
  public void setBytes(int parameterIndex, byte[] value) throws SQLException {
    binaryStreamParameters.add(Utils.bytesToHexString(value));
    String paramName = I18nSqlParser.BINARY_STREAM_OBJECT+""+binaryStreamParameters.size();
    parameters.set(parameterIndex-1, paramName);
  }

    /**
     *Adds a feature to the Batch attribute of the I18nStatement object
     *
     * @param  p0                The feature to be added to the Batch attribute
     * @exception  SQLException  Description of Exception
     * @since
     */
    public void addBatch(String p0) throws SQLException
    {
        throw new SQLException("Not Supported !");
    }


    /**
     *Description of the Method
     *
     * @exception  SQLException  Description of Exception
     * @since
     */
    public void clearBatch() throws SQLException
    {
        throw new SQLException("Not Supported !");
    }


    /**
     *Description of the Method
     *
     * @return                   Description of the Returned Value
     * @exception  SQLException  Description of Exception
     * @since
     */
    public int[] executeBatch() throws SQLException
    {
        throw new SQLException("Not Supported !");
    }

    //---------------------------------------------------------------------
    // JDBC 3.0
    //---------------------------------------------------------------------

    public boolean getMoreResults(int current) throws SQLException {
        throw new UnsupportedOperationException("Statement.getMoreResults(int) unsupported");
    }

    public ResultSet getGeneratedKeys() throws SQLException {
        throw new UnsupportedOperationException("Statement.getGeneratedKeys() unsupported");
    }

    public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
        throw new UnsupportedOperationException("Statement.executeUpdate(String,int) unsupported");
    }

    public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
        throw new UnsupportedOperationException("Statement.executeUpdate(String,int[]) unsupported");
    }

    public int executeUpdate(String sql, String[] columnNames) throws SQLException {
        throw new UnsupportedOperationException("Statement.executeUpdate(String,String[]) unsupported");
    }

    public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
        throw new UnsupportedOperationException("Statement.execute(String,int) unsupported");
    }

    public boolean execute(String sql, int[] columnIndexes) throws SQLException {
        throw new UnsupportedOperationException("Statement.execute(String,int[]) unsupported");
    }

    public boolean execute(String sql, String[] columnNames) throws SQLException {
        throw new UnsupportedOperationException("Statement.execute(String,String[]) unsupported");
    }

    public int getResultSetHoldability() throws SQLException {
        throw new UnsupportedOperationException("Statement.getResultSetHoldability() unsupported");
    }



  public ResultSet executeQuery() throws SQLException {
    if( !prepareSql())
        throw new SQLException("Error with prepared statement  !");
    return executeQuery(this.sqlPrepared);

  }
  public int executeUpdate() throws SQLException {
    if( !prepareSql())
        throw new SQLException("Error with prepared statement  !");
    executeUpdate(this.sqlPrepared);
    return 0;
  }





  public void setNull(int parameterIndex, int sqlType) throws SQLException {
    this.setString(parameterIndex, null );
  }

  public void setBoolean(int parameterIndex, boolean value) throws SQLException {
    this.setString(parameterIndex, String.valueOf(value) );
  }

  public void setByte(int parameterIndex, byte value) throws SQLException {
    this.setString(parameterIndex, String.valueOf(value) );
  }

  public void setShort(int parameterIndex, short value) throws SQLException {
    this.setString(parameterIndex, String.valueOf(value) );
  }

  public void setInt(int parameterIndex, int value) throws SQLException {
    this.setString(parameterIndex, String.valueOf(value) );
  }

  public void setLong(int parameterIndex, long value) throws SQLException {
    this.setString(parameterIndex, String.valueOf(value) );
  }

  public void setFloat(int parameterIndex, float value) throws SQLException {
    this.setString(parameterIndex, String.valueOf(value) );
  }

  public void setDouble(int parameterIndex, double value) throws SQLException {
    this.setString(parameterIndex, String.valueOf(value) );
  }

  public void setBigDecimal(int parameterIndex, BigDecimal value) throws SQLException {
    this.setString( parameterIndex, value.toString() );
  }
  public void setDate(int parameterIndex, Date x) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setDate() not yet implemented.");
  }
  public void setTime(int parameterIndex, Time x) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setTime() not yet implemented.");
  }
  public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setTimestamp() not yet implemented.");
  }
  public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setAsciiStream() not yet implemented.");
  }
  public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setUnicodeStream() not yet implemented.");
  }

  public void clearParameters() throws SQLException {
    this.sqlPrepared = this.sqlForPrepare;
    for(int i = 0; i < parameters.size(); i++)
      parameters.set(i, null);
  }
  public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setObject() not yet implemented.");
  }
  public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setObject() not yet implemented.");
  }
  public void setObject(int parameterIndex, Object x) throws SQLException {
    if( x == null )
       x = new String("null");
     setString( parameterIndex, x.toString() );
  }
  public boolean execute() throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method execute() not yet implemented.");
  }
  public void addBatch() throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method addBatch() not yet implemented.");
  }
  public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setCharacterStream() not yet implemented.");
  }
  public void setRef(int i, Ref x) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setRef() not yet implemented.");
  }

  public void setClob(int i, Clob x) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setClob() not yet implemented.");
  }
  public void setArray(int i, Array x) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setArray() not yet implemented.");
  }
  public ResultSetMetaData getMetaData() throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method getMetaData() not yet implemented.");
  }
  public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setDate() not yet implemented.");
  }
  public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setTime() not yet implemented.");
  }
  public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException("Method setTimestamp() not yet implemented.");
  }
  public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException {
    this.setString(paramIndex, null );
  }

  public void setURL(int parameterIndex, URL x) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException(
        "Method setURL() not yet implemented.");
  }

  public ParameterMetaData getParameterMetaData() throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException(
        "Method getParameterMetaData() not yet implemented.");
  }

  public void setBinaryStream(int parameterIndex, InputStream value, int length) throws
      SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException(
        "Method setBinaryStream() not yet implemented.");
  }

  public void setBlob(int parameterIndex, Blob value) throws SQLException {
    /**@todo Implement this java.sql.PreparedStatement method*/
    throw new java.lang.UnsupportedOperationException(
        "Method setBlob() not yet implemented.");
  }

  public String getSqlStatement() {
      return sql;
    }
    
	public I18nProperties getProperties() {
		   return properties;
	   }

}

⌨️ 快捷键说明

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