本文整理汇总了Java中org.knowm.yank.Yank类的典型用法代码示例。如果您正苦于以下问题:Java Yank类的具体用法?Java Yank怎么用?Java Yank使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Yank类属于org.knowm.yank包,在下文中一共展示了Yank类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertTest
import org.knowm.yank.Yank; //导入依赖的package包/类
public static long insertTest(Test test) {
if (test.getStatus() == null) {
LOGGER.warn("Test {} for build {} has no status. Setting the status to error.", test.getName(), test.getBuildId());
test.setStatus("error");
}
Object[] params = new Object[]{
test.getBuildId(),
test.getTaskId(),
test.getTestId(),
test.getName(),
test.getClassName(),
test.getStatus(),
test.durationInMillis()
};
long newId = Yank.insertSQLKey("INSERT_TEST", params);
LOGGER.debug("Inserted test {} for build {}", test.getName(), test.getBuildId());
return newId;
}
示例2: doCreateItemsTableIfNot
import org.knowm.yank.Yank; //导入依赖的package包/类
@Override
public ItemsVO doCreateItemsTableIfNot(ItemsVO vo) {
// boolean tableExists = Yank.queryScalar(SQL_IF_TABLE_EXISTS.replace("#searchTable#",
// vo.getItemsManageTable().toUpperCase()), String.class, null) == null;
boolean tableExists = doIfTableExists(vo);
if (!tableExists) {
String sql = StringUtilsExt.replaceArrayMerge(SQL_CREATE_ITEMS_TABLE_IF_NOT,
new String[] { "#itemsManageTable#", "#colname#", "#coltype#" },
new String[] { vo.getItemsManageTable().toUpperCase(), vo.getColname(), vo.getColtype() });
logger.debug("JDBC::doCreateItemsTableIfNot tableExists={} therefore sql={}", tableExists, sql);
Yank.execute(sql, null);
} else {
logger.debug("JDBC::doCreateItemsTableIfNot tableExists={}, did not CREATE TABLE", tableExists);
}
return vo;
}
示例3: getGuild
import org.knowm.yank.Yank; //导入依赖的package包/类
public DbGuild getGuild(IGuild guild){
if(Karren.conf.getAllowSQLRW()){
if(!dbGuildCache.containsKey(guild.getStringID())) {
String sql = "INSERT IGNORE Guild (GuildID, GuildOwner, GuildName, CommandPrefix, RollDifficulty, MaxVolume, RandomRange, OverrideChannel) VALUES (?, ?, ?, null, -1, 40, 0, 0)";
Object[] params = {guild.getStringID(), guild.getOwner().getName(), guild.getName()};
Yank.execute(sql, params);
sql = "SELECT * FROM Guild WHERE GuildID=?";
Object[] params2 = {guild.getStringID()};
DbGuild dbGuild = Yank.queryBean(sql, DbGuild.class, params2);
dbGuildCache.put(guild.getStringID(), dbGuild);
return dbGuild;
} else {
return dbGuildCache.get(guild.getStringID());
}
}
return null;
}
示例4: getWordCount
import org.knowm.yank.Yank; //导入依赖的package包/类
public DbWordcount getWordCount(String word){
if(Karren.conf.getAllowSQLRW()) {
if(!dbWordcountCache.containsKey(word)) {
String sql = "INSERT IGNORE WordCounts (WordID, Word, Count, CountStarted) VALUES (null, ?, 1, null)";
Object[] params = {word};
Yank.execute(sql, params);
sql = "SELECT * FROM WordCounts WHERE Word=?";
DbWordcount dbWordcount = Yank.queryBean(sql, DbWordcount.class, params);
dbWordcountCache.put(word, dbWordcount);
return dbWordcount;
} else {
return dbWordcountCache.get(word);
}
}
return null;
}
示例5: getUserData
import org.knowm.yank.Yank; //导入依赖的package包/类
public DbUser getUserData(IUser user){
if(Karren.conf.getAllowSQLRW()) {
if(!dbUserCache.containsKey(user.getStringID())) {
String sql = "INSERT IGNORE User (UserID, TimeLeft) VALUES (?, null)";
Object[] params = {user.getLongID()};
Yank.execute(sql, params);
sql = "SELECT * FROM User WHERE UserID=?";
Object[] params2 = {user.getLongID()};
DbUser dbUser = Yank.queryBean(sql, DbUser.class, params2);
dbUserCache.put(user.getStringID(), dbUser);
return dbUser;
} else {
return dbUserCache.get(user.getStringID());
}
}
return null;
}
示例6: cleanupBot
import org.knowm.yank.Yank; //导入依赖的package包/类
public void cleanupBot(){
Karren.bot.isKill = true;
//Unhook and shutdown interaction system
Karren.bot.client.getDispatcher().unregisterListener(Karren.bot.interactionListener);
Karren.bot.ic.loadDefaultInteractions();
Yank.releaseAllConnectionPools();
//Interactions reset to default state and unregistered
if(Karren.bot.ar.isAlive())
Karren.bot.ar.setKill(true);
if(Karren.bot.cm.isAlive())
Karren.bot.cm.kill();
if(Karren.bot.client.isReady()) {
try {
Karren.bot.client.logout();
} catch (DiscordException e) {
e.printStackTrace();
}
}
Karren.bot = null;
System.gc();
}
示例7: handle
import org.knowm.yank.Yank; //导入依赖的package包/类
@Override
public void handle(ReadyEvent event){
//Initialize database connection pool
Karren.log.info("Initializing Yank database pool");
Properties dbSettings = new Properties();
dbSettings.setProperty("jdbcUrl", "jdbc:mysql://" + conf.getSqlhost() + ":" + conf.getSqlport() + "/" + conf.getSqldb() + "?useUnicode=true&characterEncoding=UTF-8");
dbSettings.setProperty("username", conf.getSqluser());
dbSettings.setProperty("password", conf.getSqlpass());
Yank.setupDefaultConnectionPool(dbSettings);
//Start auto reminder
Karren.bot.getAr().start();
//Start ChannelMonitor
Karren.bot.getCm().start();
if(!Karren.conf.isTestMode())
event.getClient().changePresence(StatusType.ONLINE, ActivityType.PLAYING, "KarrenSama Ver." + Karren.botVersion);
else
event.getClient().changePresence(StatusType.ONLINE, ActivityType.PLAYING, "TEST MODE");
}
示例8: getDatabaseProductName
import org.knowm.yank.Yank; //导入依赖的package包/类
private static String getDatabaseProductName() {
if (databaseProductName.get() == null) {
synchronized (databaseProductName) {
if (databaseProductName.get() == null) {
try (Connection connection = Yank.getDefaultConnectionPool().getConnection()) {
databaseProductName.set(connection.getMetaData().getDatabaseProductName());
LOGGER.info("Connected to a {} database.", databaseProductName.get());
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
}
return databaseProductName.get();
}
示例9: loadSqlQueries
import org.knowm.yank.Yank; //导入依赖的package包/类
/**
* Loads all of the SQL queries stored in a properties file specified by GE_EXPORT_SCHEMA_PROPERTY_KEY, or 'postgres-sql.properties'
*/
public static void loadSqlQueries() {
if (!sqlQueriesLoaded.get()) {
synchronized (sqlQueriesLoaded) {
if (!sqlQueriesLoaded.getAndSet(true)) {
String propertiesFile = isMySql() ? "mysql-sql.properties" : "postgres-sql.properties";
LOGGER.info("Loading SQL queries from {}", propertiesFile);
Properties createTableProps = PropertiesUtils.getPropertiesFromClasspath(propertiesFile);
Yank.addSQLStatements(createTableProps);
}
}
}
}
示例10: insertCustomValue
import org.knowm.yank.Yank; //导入依赖的package包/类
public static long insertCustomValue(CustomValue cv) {
Object[] params = new Object[]{
cv.getBuildId(),
cv.getKey(),
cv.getValue(),
};
long newId = Yank.insertSQLKey("INSERT_CUSTOM_VALUE", params);
LOGGER.debug("Inserted custom value with key {} for build {}", cv.getKey(), cv.getBuildId());
return newId;
}
示例11: insertBuild
import org.knowm.yank.Yank; //导入依赖的package包/类
public static long insertBuild(Build build) {
LOGGER.debug("Inserting build {} into the database.", build.getBuildId());
Object start;
Object finish;
if (SqlHelper.isMySql()) {
start = LocalDateTime.ofInstant(build.getTimer().getStartTime(), ZoneOffset.UTC);
finish = LocalDateTime.ofInstant(build.getTimer().getFinishTime(), ZoneOffset.UTC);
} else {
start = OffsetDateTime.ofInstant(build.getTimer().getStartTime(), ZoneId.of(build.getTimer().getTimeZoneId()));
finish = OffsetDateTime.ofInstant(build.getTimer().getFinishTime(), ZoneId.of(build.getTimer().getTimeZoneId()));
}
Object[] params = new Object[]{
build.getBuildId(),
build.getUserName(),
build.getRootProjectName(),
start,
finish,
build.getStatus(),
build.getTagsAsSingleString()
};
Long generatedId = Yank.insertSQLKey("INSERT_BUILD", params);
if (generatedId == 0) {
throw new RuntimeException("Unable to save build record for " + build.getBuildId());
}
return generatedId;
}
示例12: run
import org.knowm.yank.Yank; //导入依赖的package包/类
public static void run() {
LOGGER.info("Creating Database");
SqlHelper.loadSqlQueries();
Yank.executeSQLKey("DROP_CUSTOM_VALUES", null);
Yank.executeSQLKey("DROP_TESTS", null);
Yank.executeSQLKey("DROP_TASKS", null);
Yank.executeSQLKey("DROP_BUILDS", null);
Yank.executeSQLKey("CREATE_BUILDS", null);
Yank.executeSQLKey("CREATE_TASKS", null);
Yank.executeSQLKey("CREATE_TESTS", null);
Yank.executeSQLKey("CREATE_CUSTOM_VALUES", null);
}
示例13: setup
import org.knowm.yank.Yank; //导入依赖的package包/类
@Before
public void setup() {
String propertiesFile = System.getProperty(GE_EXPORT_TEST_DATABASE_PROPERTIES_KEY, "test-db-info.properties");
Properties dbProps = PropertiesUtils.getPropertiesFromClasspath(propertiesFile);
Yank.setThrowWrappedExceptions(true);
Yank.setupDefaultConnectionPool(dbProps);
}
示例14: openConnection
import org.knowm.yank.Yank; //导入依赖的package包/类
/***********************
* DATABASE CONNECTION *
***********************/
protected boolean openConnection() {
logger.debug("JDBC::openConnection isDriverAvailable: {}", conf.isDriverAvailable());
if (conf.isDriverAvailable() && !conf.isDbConnected()) {
logger.info("JDBC::openConnection: Driver is available::Yank setupDataSource");
Yank.setupDefaultConnectionPool(conf.getHikariConfiguration());
conf.setDbConnected(true);
return true;
} else if (!conf.isDriverAvailable()) {
logger.warn("JDBC::openConnection: no driver available!");
initialized = false;
return false;
}
return true;
}
示例15: doStoreItemValue
import org.knowm.yank.Yank; //导入依赖的package包/类
/*************
* ITEM DAOs *
*************/
@Override
public void doStoreItemValue(Item item, ItemVO vo) {
vo = storeItemValueProvider(item, vo);
String sql = StringUtilsExt.replaceArrayMerge(SQL_INSERT_ITEM_VALUE,
new String[] { "#tableName#", "#dbType#", "#tablePrimaryValue#" },
new String[] { vo.getTableName(), vo.getDbType(), sqlTypes.get("tablePrimaryValue") });
Object[] params = new Object[] { vo.getValue() };
logger.debug("JDBC::doStoreItemValue sql={} value='{}'", sql, vo.getValue());
Yank.execute(sql, params);
}