本文整理汇总了Java中org.sqlite.util.StringUtils类的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringUtils类属于org.sqlite.util包,在下文中一共展示了StringUtils类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initSql
import org.sqlite.util.StringUtils; //导入依赖的package包/类
private void initSql() {
try {
Connection conn = mockDataSource.getConnection();
Statement stmt = conn.createStatement();
List<String> aa = IOUtils.readLines(getClass().getClassLoader().getResourceAsStream("sqlite.sql"));
String s = StringUtils.join(aa, "\r\n");
String[] sqls = s.split(";");
for (int i = 0; i < sqls.length; i++) {
String sql = sqls[i];
System.out.println("初始化sql : " + sql);
stmt.execute(sql);
}
stmt.close();
conn.close();
} catch (Exception e) {
}
}
示例2: getIndexInfo
import org.sqlite.util.StringUtils; //导入依赖的package包/类
/**
* @see java.sql.DatabaseMetaData#getIndexInfo(java.lang.String, java.lang.String,
* java.lang.String, boolean, boolean)
*/
public ResultSet getIndexInfo(String c, String s, String table, boolean u, boolean approximate) throws SQLException {
ResultSet rs = null;
Statement stat = conn.createStatement();
StringBuilder sql = new StringBuilder(500);
// define the column header
// this is from the JDBC spec, it is part of the driver protocol
sql.append("select null as TABLE_CAT, null as TABLE_SCHEM, '")
.append(escape(table)).append("' as TABLE_NAME, un as NON_UNIQUE, null as INDEX_QUALIFIER, n as INDEX_NAME, ")
.append(Integer.toString(DatabaseMetaData.tableIndexOther)).append(" as TYPE, op as ORDINAL_POSITION, ")
.append("cn as COLUMN_NAME, null as ASC_OR_DESC, 0 as CARDINALITY, 0 as PAGES, null as FILTER_CONDITION from (");
// this always returns a result set now, previously threw exception
rs = stat.executeQuery("pragma index_list('" + escape(table) + "');");
ArrayList<ArrayList<Object>> indexList = new ArrayList<ArrayList<Object>>();
while (rs.next()) {
indexList.add(new ArrayList<Object>());
indexList.get(indexList.size() - 1).add(rs.getString(2));
indexList.get(indexList.size() - 1).add(rs.getInt(3));
}
rs.close();
if (indexList.size() == 0) {
// if pragma index_list() returns no information, use this null block
sql.append("select null as un, null as n, null as op, null as cn) limit 0;");
return ((CoreStatement) stat).executeQuery(sql.toString(), true);
} else {
// loop over results from pragma call, getting specific info for each index
int i = 0;
Iterator<ArrayList<Object>> indexIterator = indexList.iterator();
ArrayList<Object> currentIndex;
ArrayList<String> unionAll = new ArrayList<String>();
while (indexIterator.hasNext()) {
currentIndex = indexIterator.next();
String indexName = currentIndex.get(0).toString();
rs = stat.executeQuery("pragma index_info('" + escape(indexName) + "');");
while (rs.next()) {
StringBuilder sqlRow = new StringBuilder();
String colName = rs.getString(3);
sqlRow.append("select ").append(Integer.toString(1 - (Integer) currentIndex.get(1))).append(" as un,'")
.append(escape(indexName)).append("' as n,")
.append(Integer.toString(rs.getInt(1) + 1)).append(" as op,");
if (colName == null) { // expression index
sqlRow.append("null");
}
else {
sqlRow.append("'").append(escape(colName)).append("'");
}
sqlRow.append(" as cn");
unionAll.add(sqlRow.toString());
}
rs.close();
}
String sqlBlock = StringUtils.join(unionAll, " union all ");
return ((CoreStatement) stat).executeQuery(sql.append(sqlBlock).append(");").toString(), true);
}
}