本文整理汇总了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;
}
}
示例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());
}
}
示例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());
}
}
示例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;
}
}
示例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());
}
}
示例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;
}
}
示例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;
}
}
示例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());
}
}
示例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());
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}