Java SQL PreparedStatement setByte(PreparedStatement statement, int index, Byte value)

Here you can find the source of setByte(PreparedStatement statement, int index, Byte value)

Description

Sets a SQL parameter of type byte using a prepared SQL statement, an index and a value.

License

Open Source License

Parameter

Parameter Description
statement - Prepared SQL statement.
index - Parameter index.
value - Parameter value.

Declaration

public static void setByte(PreparedStatement statement, int index, Byte value) throws SQLException 

Method Source Code

//package com.java2s;
/*//from   w  ww.  ja v a  2  s. c o  m
 * Copyright (C) 2015 Bryan W. Snipes
 * 
 * This file is part of the JDistil web application framework.
 * 
 * JDistil is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * JDistil is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with JDistil.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.sql.PreparedStatement;

import java.sql.SQLException;

import java.sql.Types;

public class Main {
    /**
      Sets a SQL parameter of type byte using a prepared SQL statement, an index
      and a value.
      @param statement - Prepared SQL statement.
      @param index - Parameter index.
      @param value - Parameter value.
    */
    public static void setByte(PreparedStatement statement, int index, Byte value) throws SQLException {

        if (statement != null) {

            // Set parameter
            if (value == null) {
                statement.setNull(index, Types.TINYINT);
            } else {
                statement.setByte(index, value.byteValue());
            }
        }
    }
}

Related

  1. prepareStatementForwardReadOnly(Connection conn, String name, String sql)
  2. putArgsToStatement(PreparedStatement stmt, List args)
  3. query(List paramList, Connection conn, PreparedStatement pstmt)
  4. runInsertLong(PreparedStatement s)
  5. saveResourceInfoRecord(long resourceId, long propertyId, String propertyValue, String userId, PreparedStatement ps)
  6. setBytes(PreparedStatement pstmt, int index, byte[] bytes)
  7. setValue(PreparedStatement ps, int paramIndex, Object inValue)
  8. setValue(PreparedStatement ps, int posicion, int tipo, String strDefault, String strValor)
  9. setValueIndex(PreparedStatement stmt, int index, int valueIndex)

  10. HOME | Copyright © www.java2s.com 2016