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


Java StringUtils类代码示例

本文整理汇总了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) {
	}
}
 
开发者ID:tonyruiyu,项目名称:dubbo-mock,代码行数:20,代码来源:BootStartServer.java

示例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);
    }
}
 
开发者ID:xerial,项目名称:sqlite-jdbc,代码行数:72,代码来源:JDBC3DatabaseMetaData.java


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