List of usage examples for org.apache.commons.dbutils QueryLoader load
public synchronized Map<String, String> load(String path) throws IOException
From source file:ca.on.gov.jus.icon.common.util.JDBCUtils.java
/** * Loads a Map of query names to SQL values. * The Maps are cached so a subsequent request to load queries * from the same path will return the cached Map. * /*from ww w .j a va2s. c om*/ * The default "/SQLStatements.properties" path will be used * if the propFilePath parameter is set to null. * * Note: The property file path not a file system path * If you had a jarred SQLStatements.properties file in the * ca.olgc.ci.common package you would pass * "/ca/olgc/ci/common/SQLStatements.properties" to this method. * * @param propFilePath The path that the ClassLoader will use to find the file. * @return Map Collection of SQL statements. * @exception IOException Thrown if loading the properties file fails. */ static public Map getAllSQLStatements(String propFilePath) throws IOException { Map sqlStatments = null; // Use the default property file path if it is not provided. if (propFilePath == null) { propFilePath = SQL_STATEMENTS_PROP_FILE; } // Get the singleton Query Loader object. QueryLoader loader = QueryLoader.instance(); // Get the collection of SQL statements from the Query Loader. sqlStatments = loader.load(propFilePath); return sqlStatments; }
From source file:by.jdbc.dbutils.QueryLoaderTest.java
public void testLoad() throws IOException { try {/*from w w w . ja v a2s. co m*/ QueryLoader loader = QueryLoader.instance(); Map<String, String> q = loader.load(QUERIES); Map<String, String> q2 = loader.load(QUERIES); loader.unload(QUERIES); Map<String, String> q3 = loader.load(QUERIES); } catch (IllegalArgumentException e) { // TODO Figure out why the Maven build can't find the properties // file. The tests run fine in Eclipse so just catch this // exception for now. } }
From source file:net.orpiske.ssps.common.db.version.DbVersionDao.java
/** * Constructor//from w w w.j a v a2s.c om * @param databaseManager The database manager * @throws net.orpiske.ssps.common.db.exceptions.DatabaseInitializationException if it fails to read the queries for this * DAO. */ public DbVersionDao(final DatabaseManager databaseManager) throws DatabaseInitializationException { super(databaseManager); QueryLoader queryLoader = QueryLoader.instance(); try { queries = queryLoader.load("/net/orpiske/ssps/common/db/version/DbVersion.properties"); } catch (IOException e) { throw new DatabaseInitializationException("Unable to load queries: " + e.getMessage(), e); } }
From source file:net.orpiske.ssps.common.registry.SoftwareInventoryDao.java
/** * Constructor//from w w w . j ava2s . co m * @param databaseManager The database manager * @throws DatabaseInitializationException if it fails to read the queries for this * DAO. */ public SoftwareInventoryDao(final DatabaseManager databaseManager) throws DatabaseInitializationException { super(databaseManager); QueryLoader queryLoader = QueryLoader.instance(); try { queries = queryLoader.load("/net/orpiske/ssps/common/registry/SoftwareInventory.properties"); } catch (IOException e) { throw new DatabaseInitializationException("Unable to load queries: " + e.getMessage(), e); } }
From source file:net.orpiske.ssps.common.dependencies.cache.DependencyCacheDao.java
/** * Constructor//from w w w . ja v a2s. co m * @param databaseManager The database manager * @throws net.orpiske.ssps.common.db.exceptions.DatabaseInitializationException if it fails to read the queries for this * DAO. */ public DependencyCacheDao(final DatabaseManager databaseManager) throws DatabaseInitializationException { super(databaseManager); QueryLoader queryLoader = QueryLoader.instance(); try { queries = queryLoader.load("/net/orpiske/ssps/common/dependencies/cache/DependencyCache.properties"); } catch (IOException e) { throw new DatabaseInitializationException("Unable to load queries: " + e.getMessage(), e); } }
From source file:net.orpiske.ssps.common.repository.search.cache.PackageCacheDao.java
/** * Constructor/* www. jav a 2s. c o m*/ * @param databaseManager The database manager * @throws net.orpiske.ssps.common.db.exceptions.DatabaseInitializationException if it fails to read the queries for this * DAO. */ public PackageCacheDao(final DatabaseManager databaseManager) throws DatabaseInitializationException { super(databaseManager); QueryLoader queryLoader = QueryLoader.instance(); try { queries = queryLoader.load("/net/orpiske/ssps/common/repository/search/cache/PackageCache.properties"); } catch (IOException e) { throw new DatabaseInitializationException("Unable to load queries: " + e.getMessage(), e); } }