com.tectonica.jdbc.SqliteUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tectonica-commons Show documentation
Show all versions of tectonica-commons Show documentation
Set of Java utility classes, all completely independent, to provide lightweight solutions for common situations
/*
* Copyright (C) 2014 Zach Melamed
*
* Latest version available online at https://github.com/zach-m/tectonica-commons
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tectonica.jdbc;
import javax.sql.DataSource;
import org.sqlite.SQLiteDataSource;
/**
* Generator for SQLite Connection Pool. Requires:
*
*
* <dependency>
* <groupId>org.xerial</groupId>
* <artifactId>sqlite-jdbc</artifactId>
* </dependency>
*
*
* @author Zach Melamed
*/
public class SqliteUtil
{
public static JDBC connect(String connStr)
{
try
{
Class.forName("org.sqlite.JDBC");
}
catch (ClassNotFoundException e)
{
throw new RuntimeException(e);
}
DataSource connPool = new SQLiteDataSource();
((SQLiteDataSource) connPool).setUrl(connStr);
return new JDBC(connPool);
}
}