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


Java Statement.closeOnCompletion方法代码示例

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


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

示例1: hasAProfile

import java.sql.Statement; //导入方法依赖的package包/类
public boolean hasAProfile(User user)
{
    try
    {
        Statement statement = connection.createStatement();
        statement.closeOnCompletion();

        try(ResultSet results = statement.executeQuery(String.format("SELECT * FROM PROFILES WHERE USER_ID = %s", user.getId())))
        {
            return results.next();
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return false;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:19,代码来源:ProfileDataManager.java

示例2: addTag

import java.sql.Statement; //导入方法依赖的package包/类
public void addTag(String name, String content, Long owner)
{
    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        statement.closeOnCompletion();
        try(ResultSet results = statement.executeQuery(String.format("SELECT tag_id, tag_name, tag_content, tag_owner FROM TAGS WHERE tag_name = \"%s\"", name)))
        {
            results.moveToInsertRow();
            results.updateString("tag_name", name);
            results.updateString("tag_content", content);
            results.updateLong("tag_owner", owner);
            results.insertRow();
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:21,代码来源:TagDataManager.java

示例3: editTag

import java.sql.Statement; //导入方法依赖的package包/类
public void editTag(String name, String content)
{
    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        statement.closeOnCompletion();
        try(ResultSet results = statement.executeQuery(String.format("SELECT tag_id, tag_name, tag_content FROM TAGS WHERE tag_name = \"%s\"", name)))
        {
            results.moveToInsertRow();
            results.updateString("tag_content", content);
            results.insertRow();
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:19,代码来源:TagDataManager.java

示例4: getTagContent

import java.sql.Statement; //导入方法依赖的package包/类
public String getTagContent(String name)
{
    try
    {
        Statement statement = connection.createStatement();
        statement.closeOnCompletion();
        String content;
        try (ResultSet results = statement.executeQuery(String.format("SELECT tag_id, tag_name, tag_content FROM TAGS WHERE TAG_NAME = \"%s\"", name)))
        {
            if(results.next())
                content = results.getString("tag_content");
            else content=null;
        }
        return content;
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:22,代码来源:TagDataManager.java

示例5: removeTag

import java.sql.Statement; //导入方法依赖的package包/类
public void removeTag(String name)
{
    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        try(ResultSet results = statement.executeQuery(String.format("SELECT * FROM TAGS WHERE TAG_NAME = \"%s\"", name)))
        {
            if(results.next())
            {
                results.updateInt("tag_id", 0);
                results.updateRow();
            }
        }
        statement.executeUpdate(String.format("DELETE FROM TAGS WHERE tag_name = \"%s\"", name));
        statement.closeOnCompletion();
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:22,代码来源:TagDataManager.java

示例6: getTagOwner

import java.sql.Statement; //导入方法依赖的package包/类
public Long getTagOwner(String name)
{
    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        statement.closeOnCompletion();
        try(ResultSet results = statement.executeQuery(String.format("SELECT tag_id, tag_name, tag_owner FROM TAGS WHERE tag_name = \"%s\"", name)))
        {
            if(results.next())
                return results.getLong("tag_owner");
            else
                return null;
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:21,代码来源:TagDataManager.java

示例7: isTagImported

import java.sql.Statement; //导入方法依赖的package包/类
public boolean isTagImported(String name, Long guild)
{
    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        statement.closeOnCompletion();
        try(ResultSet results = statement.executeQuery(String.format("SELECT tag_id, tag_name FROM TAGS WHERE tag_name = \"imported-%s:%s\"", guild, name)))
        {
            return results.next();
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return false;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:18,代码来源:TagDataManager.java

示例8: importTag

import java.sql.Statement; //导入方法依赖的package包/类
public void importTag(String name, String content, Long owner, Long guild)
{
    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        statement.closeOnCompletion();
        try(ResultSet results = statement.executeQuery(String.format("SELECT tag_id, tag_name, tag_content, tag_owner FROM TAGS WHERE tag_name = \"%s\"", name)))
        {
            if(results.next())
            {
                results.moveToInsertRow();
                results.updateString("tag_name", "imported-"+guild+":"+name);
                results.updateString("tag_content", content);
                results.updateLong("tag_owner", owner);
                results.insertRow();
            }
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:24,代码来源:TagDataManager.java

示例9: unImportTag

import java.sql.Statement; //导入方法依赖的package包/类
public void unImportTag(String name, Long guild)
{
    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        try(ResultSet results = statement.executeQuery(String.format("SELECT tag_id, tag_name, imported FROM TAGS WHERE tag_name = \"imported-%s:%s\"", guild, name)))
        {
            if(results.next())
            {
                results.updateInt("tag_id", 0);
                results.updateRow();
            }
        }
        statement.executeUpdate(String.format("DELETE FROM TAGS WHERE tag_name = \"imported-%s:%s\"", guild, name));
        statement.closeOnCompletion();
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:22,代码来源:TagDataManager.java

示例10: getImportedTags

import java.sql.Statement; //导入方法依赖的package包/类
public List<ImportedTag> getImportedTags()
{
    List<ImportedTag> tags = new LinkedList<>();

    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        statement.closeOnCompletion();
        try(ResultSet results = statement.executeQuery("SELECT tag_id, tag_name, tag_content, tag_owner FROM TAGS WHERE tag_name LIKE \'imported-%\'"))
        {
            while(results.next())
                tags.add(new ImportedTagImpl(results.getLong("tag_id"),
                        results.getString("tag_name"),
                        results.getString("tag_content"),
                        results.getLong("tag_owner"),
                        Long.valueOf(results.getString("tag_name").split(":")[0].split("-")[1])));

            return tags.isEmpty()?null:tags;
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:27,代码来源:TagDataManager.java

示例11: getImportedTagsForGuild

import java.sql.Statement; //导入方法依赖的package包/类
public List<ImportedTag> getImportedTagsForGuild(Long guild)
{
    List<ImportedTag> tags = new LinkedList<>();

    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        statement.closeOnCompletion();
        try(ResultSet results = statement.executeQuery("SELECT tag_id, tag_name, tag_content, tag_owner FROM TAGS WHERE tag_name LIKE \'imported-"+guild+":%\'"))
        {
            while(results.next())
                tags.add(new ImportedTagImpl(results.getLong("tag_id"),
                        results.getString("tag_name"),
                        results.getString("tag_content"),
                        results.getLong("tag_owner"),
                        Long.valueOf(results.getString("tag_name").split(":")[0].split("-")[1])));

            return tags.isEmpty()?null:tags;
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:27,代码来源:TagDataManager.java

示例12: hasDonated

import java.sql.Statement; //导入方法依赖的package包/类
public boolean hasDonated(User user)
{
    try
    {
        Statement statement = connection.createStatement();
        statement.closeOnCompletion();

        try(ResultSet results = statement.executeQuery(String.format("SELECT user_id, donated_amount FROM PROFILES WHERE user_id = %s", user.getId())))
        {
            if(results.next())
                if(results.getString("donated_amount")==null)
                    return false;
                else
                    return true;
            else
                return false;
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return false;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:25,代码来源:DonatorsDataManager.java

示例13: getBlacklistedUsersList

import java.sql.Statement; //导入方法依赖的package包/类
public Set<User> getBlacklistedUsersList(JDA jda)
{
    try
    {
        Statement statement = connection.createStatement();
        statement.closeOnCompletion();
        Set<User> users;

        try(ResultSet results = statement.executeQuery("SELECT * FROM BLACKLISTED_USERS"))
        {
            users = new HashSet<>();
            while(results.next())
            {
                User u = jda.retrieveUserById(results.getLong("user_id")).complete();
                if(!(u==null))
                    users.add(u);
            }
        }
        return users;
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:27,代码来源:BlacklistDataManager.java

示例14: getAmount

import java.sql.Statement; //导入方法依赖的package包/类
public String getAmount(User user)
{
    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        statement.closeOnCompletion();

        try(ResultSet results = statement.executeQuery(String.format("SELECT user_id, donated_amount FROM PROFILES WHERE user_id = %s", user.getId())))
        {
            if(results.next())
                return results.getString("donated_amount");
            else
                return null;
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:22,代码来源:DonatorsDataManager.java

示例15: getUsersThatDonated

import java.sql.Statement; //导入方法依赖的package包/类
public List<User> getUsersThatDonated(JDA jda)
{
    try
    {
        Statement statement = connection.createStatement();
        statement.closeOnCompletion();
        List<User> users;

        try(ResultSet results = statement.executeQuery("SELECT user_id, donated_amount FROM PROFILES"))
        {
            users = new LinkedList<>();
            while(results.next())
            {
                User u = jda.retrieveUserById(results.getLong("user_id")).complete();
                if(hasDonated(u))
                    users.add(u);
            }
        }
        return users;
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:27,代码来源:DonatorsDataManager.java


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