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


Java PreparedStatement.isClosed方法代码示例

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


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

示例1: disbandAlliance

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void disbandAlliance(MapleClient c, int allianceId) {
    PreparedStatement ps = null;
    try {
        ps = DatabaseConnection.getConnection().prepareStatement("DELETE FROM `alliance` WHERE id = ?");
        ps.setInt(1, allianceId);
        ps.executeUpdate();
        ps.close();
        Server.getInstance().allianceMessage(c.getPlayer().getGuild().getAllianceId(), MaplePacketCreator.disbandAlliance(allianceId), -1, -1);
        Server.getInstance().disbandAlliance(allianceId);
    } catch (SQLException sqle) {
        sqle.printStackTrace();
    } finally {
        try {
            if (ps != null && !ps.isClosed()) {
                ps.close();
            }
        } catch (SQLException ex) {
        }
    }
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:21,代码来源:NPCConversationManager.java

示例2: excluirProduto

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void excluirProduto(long id) throws SQLException, ClassNotFoundException {
    String sql = "DELETE FROM produto WHERE (produto.id=?)";

    Connection connection = null;

    PreparedStatement preparedStatement = null;
    try {
        connection = ConnectionUtils.getConnection();

        preparedStatement = connection.prepareStatement(sql);

        preparedStatement.setLong(1, id);

        preparedStatement.execute();
    } finally {
        if (preparedStatement != null && !preparedStatement.isClosed()) {
            preparedStatement.close();
        }
        if (connection != null && !connection.isClosed()) {
            connection.close();
        }
    }
}
 
开发者ID:OgumaJr,项目名称:Entrega-Final,代码行数:24,代码来源:DaoProduto.java

示例3: closeConnection

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void closeConnection(Connection con, PreparedStatement ps, ResultSet rs) throws SQLException {
    if (con.isClosed() == false) {
        con.close();
    }
    if (ps.isClosed() == false) {
        ps.close();
    }
    if (rs.isClosed() == false) {
        rs.close();
    }
}
 
开发者ID:seyidkanan,项目名称:my-diploma-work,代码行数:12,代码来源:ConnectionDB.java

示例4: hasLevel30Character

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public boolean hasLevel30Character() {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        ps = DatabaseConnection.getConnection().prepareStatement("SELECT `level` FROM `characters` WHERE accountid = ?");
        ps.setInt(1, getPlayer().getAccountID());
        rs = ps.executeQuery();
        while (rs.next()) {
            if (rs.getInt("level") >= 30) {
                return true;
            }
        }
    } catch (SQLException sqle) {
        sqle.printStackTrace();
    } finally {
        try {
            if (ps != null && !ps.isClosed()) {
                ps.close();
            }
            if (rs != null && !rs.isClosed()) {
                rs.close();
            }
        } catch (SQLException ex) {
        }
    }
    return false;
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:28,代码来源:PortalPlayerInteraction.java

示例5: updateMacs

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void updateMacs(String macData) {
    macs.addAll(Arrays.asList(macData.split(", ")));
    StringBuilder newMacData = new StringBuilder();
    Iterator<String> iter = macs.iterator();
    PreparedStatement ps = null;
    while (iter.hasNext()) {
        String cur = iter.next();
        newMacData.append(cur);
        if (iter.hasNext()) {
            newMacData.append(", ");
        }
    }
    try {
        ps = DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET macs = ? WHERE id = ?");
        ps.setString(1, newMacData.toString());
        ps.setInt(2, accId);
        ps.executeUpdate();
        ps.close();
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        try {
            if (ps != null && !ps.isClosed()) {
                ps.close();
            }
        } catch (SQLException ex) {
        }
    }
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:30,代码来源:MapleClient.java

示例6: inserirProduto

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void inserirProduto(Produto produto) throws SQLException, ClassNotFoundException {
    String sql = "INSERT INTO produto (nome, descricao, "
            + "vl_compra, vl_venda, categoria, dt_cadastro)"
            + " VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP)";

    Connection connection = null;

    PreparedStatement preparedStatement = null;
    try {
        connection = ConnectionUtils.getConnection();

        preparedStatement = connection.prepareStatement(sql);

        preparedStatement.setString(1, produto.getNome());
        preparedStatement.setString(2, produto.getDescricao());
        preparedStatement.setBigDecimal(3, produto.getValorCompra());
        preparedStatement.setBigDecimal(4, produto.getValorVenda());
        preparedStatement.setString(5, produto.getCategoria());

        preparedStatement.execute();
    } finally {
        if (preparedStatement != null && !preparedStatement.isClosed()) {
            preparedStatement.close();
        }
        if (connection != null && !connection.isClosed()) {
            connection.close();
        }
    }
}
 
开发者ID:OgumaJr,项目名称:Entrega-Final,代码行数:30,代码来源:DaoProduto.java

示例7: atualizarProduto

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void atualizarProduto(Produto produto) throws SQLException, ClassNotFoundException {
    String sql = "UPDATE produto SET nome=?, descricao=?, vl_compra=?,"
            + " vl_venda=?, categoria=? WHERE (produto.id=?)";

    Connection connection = null;

    PreparedStatement preparedStatement = null;
    try {
        connection = ConnectionUtils.getConnection();

        preparedStatement = connection.prepareStatement(sql);

        preparedStatement.setString(1, produto.getNome());
        preparedStatement.setString(2, produto.getDescricao());
        preparedStatement.setBigDecimal(3, produto.getValorCompra());
        preparedStatement.setBigDecimal(4, produto.getValorVenda());
        preparedStatement.setString(5, produto.getCategoria());
        preparedStatement.setLong(6, produto.getId());

        preparedStatement.execute();
    } finally {
        if (preparedStatement != null && !preparedStatement.isClosed()) {
            preparedStatement.close();
        }
        if (connection != null && !connection.isClosed()) {
            connection.close();
        }
    }
}
 
开发者ID:OgumaJr,项目名称:Entrega-Final,代码行数:30,代码来源:DaoProduto.java

示例8: ban

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static boolean ban(String id, String reason, boolean accountId) {
    PreparedStatement ps = null;
    try {
        Connection con = DatabaseConnection.getConnection();
        if (id.matches("/[0-9]{1,3}\\..*")) {
            ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)");
            ps.setString(1, id);
            ps.executeUpdate();
            ps.close();
            return true;
        }
        if (accountId) {
            ps = con.prepareStatement("SELECT id FROM accounts WHERE name = ?");
        } else {
            ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
        }

        boolean ret = false;
        ps.setString(1, id);
        try (ResultSet rs = ps.executeQuery()) {
            if (rs.next()) {
                try (PreparedStatement psb = DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ?")) {
                    psb.setString(1, reason);
                    psb.setInt(2, rs.getInt(1));
                    psb.executeUpdate();
                }
                ret = true;
            }
        }
        ps.close();
        return ret;
    } catch (SQLException ex) {
    } finally {
        try {
            if (ps != null && !ps.isClosed()) {
                ps.close();
            }
        } catch (SQLException e) {
        }
    }
    return false;
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:43,代码来源:MapleCharacter.java

示例9: ban

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static boolean ban(String id, String reason, boolean accountId) {
    PreparedStatement ps = null;
    try {
        Connection con = DatabaseConnection.getConnection();
        if (id.matches("/[0-9]{1,3}\\..*")) {
            ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)");
            ps.setString(1, id);
            ps.executeUpdate();
            ps.close();
            return true;
        }
        if (accountId) {
            ps = con.prepareStatement("SELECT id FROM accounts WHERE name = ?");
        } else {
            ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
        }
        boolean ret = false;
        ps.setString(1, id);
        try (ResultSet rs = ps.executeQuery()) {
            if (rs.next()) {
                try (PreparedStatement psb = DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ?")) {
                    psb.setString(1, reason);
                    psb.setInt(2, rs.getInt(1));
                    psb.executeUpdate();
                }
                ret = true;
            }
        }
        ps.close();
        return ret;
    } catch (SQLException ex) {
    } finally {
        try {
            if (ps != null && !ps.isClosed()) {
                ps.close();
            }
        } catch (SQLException e) {
        }
    }
    return false;
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:42,代码来源:MapleCharacter.java

示例10: procurarProduto

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static ArrayList<Produto> procurarProduto(String nomeProduto) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM produto WHERE (produto.nome LIKE(?))";

    ArrayList<Produto> listaProdutos = null;

    Connection connection = null;

    PreparedStatement preparedStatement = null;

    ResultSet result = null;
    try {
        connection = ConnectionUtils.getConnection();

        preparedStatement = connection.prepareStatement(sql);

        preparedStatement.setString(1, "%" + nomeProduto + "%");

        result = preparedStatement.executeQuery();

        while (result.next()) {
            if (listaProdutos == null) {
                listaProdutos = new ArrayList<>();
            }
            Produto produto = new Produto();
            produto.setId(result.getLong("id"));
            produto.setNome(result.getString("nome"));
            produto.setDescricao(result.getString("descricao"));
            produto.setValorCompra(result.getBigDecimal("vl_compra"));
            produto.setValorVenda(result.getBigDecimal("vl_venda"));
            produto.setCategoria(result.getString("categoria"));
            produto.setDtCadastro(result.getDate("dt_cadastro"));

            listaProdutos.add(produto);
        }
    } finally {
        if (result != null && !result.isClosed()) {
            result.close();
        }

        if (preparedStatement != null && !preparedStatement.isClosed()) {
            preparedStatement.close();
        }

        if (connection != null && !connection.isClosed()) {
            connection.close();
        }
    }

    return listaProdutos;
}
 
开发者ID:OgumaJr,项目名称:Entrega-Final,代码行数:51,代码来源:DaoProduto.java

示例11: obterProduto

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static Produto obterProduto(long id) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM produto WHERE (produto.id=?)";

    Connection connection = null;

    PreparedStatement preparedStatement = null;

    ResultSet result = null;
    try {
        connection = ConnectionUtils.getConnection();

        preparedStatement = connection.prepareStatement(sql);

        preparedStatement.setLong(1, id);

        result = preparedStatement.executeQuery();
        if (result.next()) {
            Produto produto = new Produto();
            produto.setId(result.getLong("id"));
            produto.setNome(result.getString("nome"));
            produto.setDescricao(result.getString("descricao"));
            produto.setValorCompra(result.getBigDecimal("vl_compra"));
            produto.setValorVenda(result.getBigDecimal("vl_venda"));
            produto.setCategoria(result.getString("categoria"));
            produto.setDtCadastro(result.getDate("dt_cadastro"));

            return produto;
        }
    } finally {
        if (result != null && !result.isClosed()) {
            result.close();
        }
        if (preparedStatement != null && !preparedStatement.isClosed()) {
            preparedStatement.close();
        }
        if (connection != null && !connection.isClosed()) {
            connection.close();
        }
    }

    return null;
}
 
开发者ID:OgumaJr,项目名称:Entrega-Final,代码行数:43,代码来源:DaoProduto.java


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