当前位置: 首页>>代码示例>>Java>>正文


Java PreparedStatement.setByte方法代码示例

本文整理汇总了Java中java.sql.PreparedStatement.setByte方法的典型用法代码示例。如果您正苦于以下问题:Java PreparedStatement.setByte方法的具体用法?Java PreparedStatement.setByte怎么用?Java PreparedStatement.setByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.PreparedStatement的用法示例。


在下文中一共展示了PreparedStatement.setByte方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: storeRecord

import java.sql.PreparedStatement; //导入方法依赖的package包/类
static void storeRecord(UUID entity, String entityType, Material material, byte blockData,
                        Location location, ItemStack holding) throws SQLException {
    try (Connection con = MySQLThreadPool.getInstance().getConnection()) {
        PreparedStatement bigSt = con.prepareStatement("INSERT INTO block_break_stat " +
                "(entity, entity_type, block_material, block_data, loc_world, loc_x, loc_y, loc_z, holding_item) VALUE " +
                "(UNHEX(?), ?, ?, ?, ?, ?, ?, ?, ?)");
        bigSt.setString(1, entity.toString().replace("-", ""));
        bigSt.setString(2, entityType);
        bigSt.setString(3, material.name());
        bigSt.setByte(4, blockData);
        bigSt.setString(5, location.getWorld().getName());
        bigSt.setInt(6, location.getBlockX());
        bigSt.setInt(7, location.getBlockY());
        bigSt.setInt(8, location.getBlockZ());
        bigSt.setString(9, Util.serialiseItemStack(holding));
        bigSt.execute();

        PreparedStatement smallSt = con.prepareStatement("INSERT INTO block_break_stat_simple " +
                "(player, material, block_data, amount) VALUE (UNHEX(?), ?, ?, ?) ON DUPLICATE KEY UPDATE amount=amount+VALUES(amount)");
        smallSt.setString(1, entity.toString().replace("-", ""));
        smallSt.setString(2, material.name());
        smallSt.setByte(3, blockData);
        smallSt.setInt(4, 1);
        smallSt.execute();
    }
}
 
开发者ID:Lolmewn,项目名称:Stats4,代码行数:27,代码来源:BlockBreakStat.java

示例2: writeToConnection

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void writeToConnection(Connection c) throws SQLException {
	String world = block.getWorldUniqueId().toString();
	
	PreparedStatement ps = c.prepareStatement(QUERY);
	ps.setInt(1, block.getPosition().getX());
	ps.setInt(2, block.getPosition().getY());
	ps.setInt(3, block.getPosition().getZ());
	ps.setInt(4, Database.worldCache.getDataId(c, world));
	ps.setByte(5, (byte) type.ordinal());
	ps.setInt(6, Database.causeCache.getDataId(c, cause));
	ps.setInt(7, Database.idCache.getDataId(c, block.getState().getType().getId()));
	
	ps.setNull(8, Types.VARCHAR);
	try {
		String data = DataUtils.dataToString(block.toContainer());
		if (data != null)
			ps.setString(8, data);
	} catch (IOException e) {
		e.printStackTrace();
	}

		
	ps.setLong(9, timestamp);
	ps.executeUpdate();
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:27,代码来源:BlockQueueEntry.java

示例3: createPet

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static int createPet(int itemid, byte level, int closeness, int fullness) {
    try {
        PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO pets (name, level, closeness, fullness, summoned) VALUES (?, ?, ?, ?, 0)", Statement.RETURN_GENERATED_KEYS);
        ps.setString(1, MapleItemInformationProvider.getInstance().getName(itemid));
        ps.setByte(2, level);
        ps.setInt(3, closeness);
        ps.setInt(4, fullness);
        ps.executeUpdate();
        ResultSet rs = ps.getGeneratedKeys();
        int ret = -1;
        if (rs.next()) {
            ret = rs.getInt(1);
            rs.close();
            ps.close();
        }
        return ret;
    } catch (SQLException e) {
        return -1;
    }
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:21,代码来源:MaplePet.java

示例4: getBinder

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
	return new BasicBinder<X>( javaTypeDescriptor, this ) {
		@Override
		protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
			st.setByte( index, javaTypeDescriptor.unwrap( value, Byte.class, options ) );
		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:TinyIntTypeDescriptor.java

示例5: testTinyIntComplex

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void testTinyIntComplex() {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        ps = netConn.prepareStatement(
            "INSERT INTO alltypes(id, ti) VALUES(?, ?)");
        ps.setInt(1, 3);
        ps.setByte(2, (byte) 200);
        assertEquals(1, ps.executeUpdate());
        ps.setInt(1, 4);
        assertEquals(1, ps.executeUpdate());
        ps.close();
        netConn.commit();
        ps = netConn.prepareStatement(
            "SELECT * FROM alltypes WHERE ti = ?");
        ps.setByte(1, (byte) 200);
        rs = ps.executeQuery();
        assertTrue("Got no rows with ti = 200", rs.next());
        assertEquals(Integer.class, rs.getObject("ti").getClass());
        assertTrue("Got only one row with ti = 200", rs.next());
        assertEquals((byte) 200, rs.getByte("ti"));
        assertFalse("Got too many rows with ti = 200", rs.next());
    } catch (SQLException se) {
        junit.framework.AssertionFailedError ase
            = new junit.framework.AssertionFailedError(se.getMessage());
        ase.initCause(se);
        throw ase;
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (ps != null) {
                ps.close();
            }
        } catch(Exception e) {
        }
    }
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:40,代码来源:TestOdbcTypes.java

示例6: writeToConnection

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void writeToConnection(Connection c) throws SQLException {
	Location<World> loc = carrier.getLocation();
	
	PreparedStatement ps = c.prepareStatement(QUERY);
	ps.setInt(1, loc.getBlockX());
	ps.setInt(2, loc.getBlockY());
	ps.setInt(3, loc.getBlockZ());
	ps.setInt(4, Database.worldCache.getDataId(c, carrier.getWorld().getUniqueId().toString()));
	ps.setByte(5, (byte) type.ordinal());
	ps.setInt(6, slot);
	ps.setInt(7, Database.causeCache.getDataId(c, cause.getUniqueId().toString()));
	ps.setInt(8, Database.idCache.getDataId(c, item.getType().getId()));
	ps.setByte(9, (byte) item.getCount());
	
	ps.setNull(10, Types.VARCHAR);
	try {
		String data = DataUtils.dataToString(item.toContainer());
		if (data != null)
			ps.setString(10, data);
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	ps.setLong(11, timestamp);
	ps.executeUpdate();
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:28,代码来源:InventoryQueueEntry.java

示例7: getTransactions

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public DbIterator<TransactionImpl> getTransactions(Account account, int numberOfConfirmations, byte type, byte subtype,
                                                   int blockTimestamp, int from, int to) {
    int height = numberOfConfirmations > 0 ? getHeight() - numberOfConfirmations : Integer.MAX_VALUE;
    if (height < 0) {
        throw new IllegalArgumentException("Number of confirmations required " + numberOfConfirmations
                + " exceeds current blockchain height " + getHeight());
    }
    Connection con = null;
    try {
        StringBuilder buf = new StringBuilder();
        buf.append("SELECT * FROM transaction WHERE recipient_id = ? AND sender_id <> ? ");
        if (blockTimestamp > 0) {
            buf.append("AND block_timestamp >= ? ");
        }
        if (type >= 0) {
            buf.append("AND type = ? ");
            if (subtype >= 0) {
                buf.append("AND subtype = ? ");
            }
        }
        if (height < Integer.MAX_VALUE) {
            buf.append("AND height <= ? ");
        }
        buf.append("UNION ALL SELECT * FROM transaction WHERE sender_id = ? ");
        if (blockTimestamp > 0) {
            buf.append("AND block_timestamp >= ? ");
        }
        if (type >= 0) {
            buf.append("AND type = ? ");
            if (subtype >= 0) {
                buf.append("AND subtype = ? ");
            }
        }
        if (height < Integer.MAX_VALUE) {
            buf.append("AND height <= ? ");
        }
        buf.append("ORDER BY block_timestamp DESC, id DESC");
        buf.append(DbUtils.limitsClause(from, to));
        con = Db.getConnection();
        PreparedStatement pstmt;
        int i = 0;
        pstmt = con.prepareStatement(buf.toString());
        pstmt.setLong(++i, account.getId());
        pstmt.setLong(++i, account.getId());
        if (blockTimestamp > 0) {
            pstmt.setInt(++i, blockTimestamp);
        }
        if (type >= 0) {
            pstmt.setByte(++i, type);
            if (subtype >= 0) {
                pstmt.setByte(++i, subtype);
            }
        }
        if (height < Integer.MAX_VALUE) {
            pstmt.setInt(++i, height);
        }
        pstmt.setLong(++i, account.getId());
        if (blockTimestamp > 0) {
            pstmt.setInt(++i, blockTimestamp);
        }
        if (type >= 0) {
            pstmt.setByte(++i, type);
            if (subtype >= 0) {
                pstmt.setByte(++i, subtype);
            }
        }
        if (height < Integer.MAX_VALUE) {
            pstmt.setInt(++i, height);
        }
        DbUtils.setLimits(++i, pstmt, from, to);
        return getTransactions(con, pstmt);
    } catch (SQLException e) {
        DbUtils.close(con);
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:78,代码来源:BlockchainImpl.java

示例8: setValue

import java.sql.PreparedStatement; //导入方法依赖的package包/类
private static void setValue(PreparedStatement preStmt,int index,Value value)
{
	try 
	{
		if(value.isStringValue())
		{
			preStmt.setString(index, value.getString_value());
		}
		else if(value.isIntValue())
		{
			preStmt.setInt(index, value.getInt_value());
		}
		else if(value.isDoubleValue())
		{
			preStmt.setDouble(index, value.getDouble_value());
		}
		else if(value.isBooleanValue())
		{
			preStmt.setBoolean(index, value.getBoolean_value());
		}
		else if(value.isBlobValue())
		{
			preStmt.setBlob(index, value.getBlob_value());
		}
		else if(value.isBytesValue())
		{
			preStmt.setBytes(index, value.getBytes_value());
		}
		else if(value.isLongValue())
		{
			preStmt.setLong(index, value.getLong_value());
		}
		else if(value.isFloatValue())
		{
			preStmt.setFloat(index, value.getFloat_value());
		}
		else if(value.isBigdecimalValue())
		{
			preStmt.setBigDecimal(index, value.getBigdecimal_value());
		}
		else if(value.isByteValue())
		{
			preStmt.setByte(index, value.getByte_value());
		}
		else if(value.isDateValue())
		{
			preStmt.setDate(index, value.getDate_value());
		}
		else if(value.isTimeValue())
		{
			preStmt.setTime(index, value.getTime_value());
		}
		else
		{
			preStmt.setObject(index, value.getObject_value());
		}
		
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		DBCException.logException(DBCException.E_PreparedStatement, e);
	}
	
}
 
开发者ID:shaogaige,项目名称:iDataBaseConnection,代码行数:65,代码来源:SQLPreparedParamUtil.java

示例9: setNonNullParameter

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Byte parameter, JdbcType jdbcType) throws SQLException {
	ps.setByte(i, parameter);
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:5,代码来源:ByteTypeHandler.java

示例10: setValue

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
protected void setValue(PreparedStatement ps, int i, Byte value)
        throws SQLException {
    ps.setByte(i, value);
}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:6,代码来源:ConvertableEnumTypeHandler.java

示例11: dumpMobSkills

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void dumpMobSkills(PreparedStatement ps) throws Exception {
    if (!update) {
        delete("DELETE FROM wz_mobskilldata");
        System.out.println("Deleted wz_mobskilldata successfully.");
    }
    final MapleData skillz = skill.getData("MobSkill.img");
    System.out.println("Adding into wz_mobskilldata.....");

    for (MapleData ids : skillz.getChildren()) {
        for (MapleData lvlz : ids.getChildByPath("level").getChildren()) {
            this.id = Integer.parseInt(ids.getName());
            int lvl = Integer.parseInt(lvlz.getName());
            if (update && doesExist("SELECT * FROM wz_mobskilldata WHERE skillid = " + id + " AND level = " + lvl)) {
                continue;
            }
            ps.setInt(1, id);
            ps.setInt(2, lvl);
            ps.setInt(3, MapleDataTool.getInt("hp", lvlz, 100));
            ps.setInt(4, MapleDataTool.getInt("mpCon", lvlz, 0));
            ps.setInt(5, MapleDataTool.getInt("x", lvlz, 1));
            ps.setInt(6, MapleDataTool.getInt("y", lvlz, 1));
            ps.setInt(7, MapleDataTool.getInt("time", lvlz, 0)); // * 1000
            ps.setInt(8, MapleDataTool.getInt("prop", lvlz, 100)); // / 100.0
            ps.setInt(9, MapleDataTool.getInt("limit", lvlz, 0));
            ps.setInt(10, MapleDataTool.getInt("summonEffect", lvlz, 0));
            ps.setInt(11, MapleDataTool.getInt("interval", lvlz, 1)); // * 1000

            StringBuilder summ = new StringBuilder();
            List<Integer> toSummon = new ArrayList<>();
            for (int i = 0; i > -1; i++) {
                if (lvlz.getChildByPath(String.valueOf(i)) == null) {
                    break;
                }
                toSummon.add(Integer.valueOf(MapleDataTool.getInt(lvlz.getChildByPath(String.valueOf(i)), 0)));
            }
            for (Integer summon : toSummon) {
                if (summ.length() > 0) {
                    summ.append(", ");
                }
                summ.append(String.valueOf(summon));
            }
            ps.setString(12, summ.toString());
            if (lvlz.getChildByPath("lt") != null) {
                Point lt = (Point) lvlz.getChildByPath("lt").getData();
                ps.setInt(13, lt.x);
                ps.setInt(14, lt.y);
            } else {
                ps.setInt(13, 0);
                ps.setInt(14, 0);
            }
            if (lvlz.getChildByPath("rb") != null) {
                Point rb = (Point) lvlz.getChildByPath("rb").getData();
                ps.setInt(15, rb.x);
                ps.setInt(16, rb.y);
            } else {
                ps.setInt(15, 0);
                ps.setInt(16, 0);
            }
            ps.setByte(17, (byte) (MapleDataTool.getInt("summonOnce", lvlz, 0) > 0 ? 1 : 0));
            System.out.println("Added skill: " + id + " level " + lvl);
            ps.addBatch();
        }
    }
    System.out.println("Done wz_mobskilldata...");
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:66,代码来源:DumpMobSkills.java

示例12: setNonNullParameter

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setNonNullParameter(PreparedStatement ps, int i, E parameter, JdbcType jdbcType) throws SQLException {
    ps.setByte(i, parameter.getId());
}
 
开发者ID:slking1987,项目名称:mafia,代码行数:5,代码来源:EnumTypeHandler.java


注:本文中的java.sql.PreparedStatement.setByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。