public void setByte(String parameterName, byte x) throws SQLException {
   checkOpen();
   try {
     ((CallableStatement) _stmt).setByte(parameterName, x);
   } catch (SQLException e) {
     handleException(e);
   }
 }
 public void setByte(String parameterName, byte x) throws SQLException {
   checkOpen();
   try {
     _stmt.setByte(parameterName, x);
   } catch (SQLException e) {
     handleException(e);
   }
 }
Пример #3
0
  /** Sets the byte */
  @Override
  public void setByte(String parameterName, byte x) throws SQLException {
    try {
      _cstmt.setByte(parameterName, x);
    } catch (SQLException e) {
      onSqlException(e);

      throw e;
    } catch (RuntimeException e) {
      onRuntimeException(e);

      throw e;
    }
  }
Пример #4
0
  public static void actualizar(Usuario u) {
    ConnectionPool pool = ConnectionPool.getInstance();
    Connection connection = pool.getConnection();
    CallableStatement cs = null;
    try {
      cs = connection.prepareCall("{ call actualizar_usuario(?, ?, ?, ?, ?, ?) }");
      cs.setString(1, u.getNombreUsuario());
      cs.setString(2, u.getApellidoPaterno());
      cs.setString(3, u.getApellidoMterno());
      cs.setByte(4, u.getSexo());
      cs.setInt(5, u.getSucursal().getIdSucursal());
      cs.setInt(6, u.getIdUsuario());
      cs.execute();

    } catch (Exception ex) {
      ex.printStackTrace();

    } finally {
      DBUtil.closeStatement(cs);
      pool.freeConnection(connection);
    }
  }
Пример #5
0
 public Customer updateCustomer(Customer customer) {
   Connection connection = null;
   CallableStatement callableStatement = null;
   ResultSet resultSet = null;
   boolean hasResults;
   String id;
   try {
     connection = dataSource.getConnection(); // get connection from dataSource
     callableStatement = connection.prepareCall(updateCustomerSql); // prepare callable statement
     id = customer.getId();
     if (id == null) {
       callableStatement.setNull(1, Types.INTEGER);
     } else {
       callableStatement.setInt(1, Integer.parseInt(id));
     }
     if (customer.isInactive()) {
       callableStatement.setNull(2, Types.VARCHAR);
       callableStatement.setNull(3, Types.VARCHAR);
       callableStatement.setNull(4, Types.VARCHAR);
       callableStatement.setNull(5, Types.VARCHAR);
       callableStatement.setNull(6, Types.VARCHAR);
       callableStatement.setNull(7, Types.VARCHAR);
       callableStatement.setNull(8, Types.VARCHAR);
       callableStatement.setNull(9, Types.VARCHAR);
       callableStatement.setNull(10, Types.VARCHAR);
       callableStatement.setNull(11, Types.VARCHAR);
       callableStatement.setByte(12, (byte) 1);
     } else {
       callableStatement.setString(2, customer.getFirstName());
       callableStatement.setString(3, customer.getLastName());
       callableStatement.setString(4, customer.getStreetAddress());
       callableStatement.setString(5, customer.getAptAddress());
       callableStatement.setString(6, customer.getCity());
       callableStatement.setString(7, customer.getState());
       callableStatement.setString(8, customer.getZip());
       callableStatement.setString(9, customer.getPhone());
       callableStatement.setString(10, customer.getEmail());
       callableStatement.setString(11, customer.getNotes());
       callableStatement.setByte(12, (byte) 0);
     }
     hasResults = callableStatement.execute();
     if (hasResults) {
       resultSet = callableStatement.getResultSet();
       if (resultSet.next()) {
         customer.setId(resultSet.getString(1));
       } else {
         throw new SQLException("Unable to update customer.");
       }
     } else {
       throw new SQLException("Unable to update customer.");
     }
   } catch (SQLException se) {
     log.error("SQL error: ", se);
     return null;
   } finally {
     try {
       resultSet.close();
     } catch (Exception se) {
       log.error("Unable to close resultSet: ", se);
     }
     try {
       callableStatement.close();
     } catch (Exception se) {
       log.error("Unable to close callableStatement: ", se);
     }
     try {
       connection.close();
     } catch (Exception se) {
       log.error("Unable to close connection: ", se);
     }
   }
   return customer;
 }
Пример #6
0
 /** @see java.sql.PreparedStatement#setByte(int, byte) */
 public void setByte(int parameterIndex, byte x) throws SQLException {
   original.setByte(parameterIndex, x);
 }
Пример #7
0
 /** @see java.sql.CallableStatement#setByte(java.lang.String, byte) */
 public void setByte(String parameterName, byte x) throws SQLException {
   original.setByte(parameterName, x);
 }
Пример #8
0
  private static void callSetMethod(CallableStatement cs, int arg, int type, StringBuilder strbuf)
      throws Throwable {
    switch (type) {
      case Types.BIT:
      case Types.BOOLEAN:
        strbuf.append("setBoolean(" + arg + ", true)");
        cs.setBoolean(arg, true);
        break;

      case Types.TINYINT:
        strbuf.append("setByte(" + arg + ", 6)");
        cs.setByte(arg, (byte) 6);
        break;

      case Types.SMALLINT:
        strbuf.append("setShort(" + arg + ", 66)");
        cs.setShort(arg, (short) 66);
        break;

      case Types.INTEGER:
        strbuf.append("setInt(" + arg + ", 666)");
        cs.setInt(arg, 666);
        break;

      case Types.BIGINT:
        strbuf.append("setLong(" + arg + ", 666)");
        cs.setLong(arg, 666);
        break;

      case Types.FLOAT:
      case Types.REAL:
        strbuf.append("setFLoat(" + arg + ", 666)");
        cs.setFloat(arg, 666);
        break;

      case Types.DOUBLE:
        strbuf.append("setDouble(" + arg + ", 666)");
        cs.setDouble(arg, 666);
        break;

      case Types.DECIMAL:
      case Types.NUMERIC:
        strbuf.append("setBigDecimal(" + arg + ", 666.666)");
        BigDecimalHandler.setBigDecimalString(cs, arg, "666.666");
        break;

      case Types.CHAR:
      case Types.VARCHAR:
      case Types.LONGVARCHAR:
        strbuf.append("setString(" + arg + ", \"Set via setString()\")");
        cs.setString(arg, "Set via setString()");
        break;

      case Types.BINARY:
      case Types.VARBINARY:
      case Types.LONGVARBINARY:
        strbuf.append("setBytes(" + arg + ", byte[])");
        byte[] myarray = new byte[16];
        myarray[0] = (byte) 255;
        cs.setBytes(arg, myarray);
        break;

      case Types.DATE:
        strbuf.append("setDate(" + arg + ", Date.valueOf(1999-09-09))");
        cs.setDate(arg, Date.valueOf("1999-09-09"));
        break;

      case Types.TIME:
        strbuf.append("setTime(" + arg + ", Time.valueOf(09:09:09))");
        cs.setTime(arg, Time.valueOf("09:09:09"));
        break;

      case Types.TIMESTAMP:
        strbuf.append("setTimestamp(" + arg + ", Timestamp.valueOf(1999-09-09 09:09:09.999))");
        cs.setTimestamp(arg, Timestamp.valueOf("1999-09-09 09:09:09.999"));
        break;

      case Types.OTHER:
        strbuf.append("setObject(" + arg + ", new BigInteger(666))");
        cs.setObject(arg, new BigInteger("666"));
        break;

      default:
        throw new Throwable("TEST ERROR: unexpected type " + type);
    }
  }
 public void setByte(String parameterName, byte x) throws SQLException {
   passThru.setByte(parameterName, x);
 }