Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
AnalyzerBeans Copyright (C) 2014 Neopost - Customer Information Management This copyrighted material is made available to anyone wishing to use, modify, copy, or redistribute it subject to the terms and conditions of the GNU Lesser General Public License, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this distribution; if not, write to: Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA
H2 based implementation of the StorageProvider.
public final class H2StorageProvider extends SqlDatabaseStorageProvider implements StorageProvider {
	public static final String DRIVER_CLASS_NAME = "org.h2.Driver";
	private static final Logger logger = LoggerFactory.getLogger(H2StorageProvider.class);
	private static final String DATABASE_FILENAME = "h2-storage";
	private static final AtomicInteger databaseIndex = new AtomicInteger(0);
	public H2StorageProvider() {
		super("jdbc:h2:mem:ab" + .getAndIncrement());
	public H2StorageProvider(String directoryPath) {
		super("jdbc:h2:" + cleanDirectory(directoryPath) + . + );
	private static String cleanDirectory(String directoryPath) {
		File file = new File(directoryPath);
		if (file.exists() && file.isDirectory()) {
			// remove all files from previous uncleansed database
			File[] dbFiles = file.listFiles(new FilenameFilter() {
				public boolean accept(File dirString name) {
			for (File f : dbFiles) {
				boolean isDeleted = f.delete();
					.error("Directory cleaning not successful.");
		return directoryPath;
New to GrepCode? Check out our FAQ X