Package com.k42b3.kadabra

Source Code of com.k42b3.kadabra.Db

/**
* Kadabra
*
* Kadabra is an application to mirror a source folder to a destination folder.
* You can create multiple projects wich are stored in an SQLite database.
* With the command status [id] you can see wich changes are made and
* with release [id] you update the changes. You can use different handler
* like System or FTP.
*
* Copyright (c) 2010, 2011 Christoph Kappestein <k42b3.x@gmail.com>
*
* This file is part of oat. oat is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation,
* either version 3 of the License, or at any later version.
*
* oat 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with oat. If not, see <http://www.gnu.org/licenses/>.
*/

package com.k42b3.kadabra;

import java.io.File;

import com.almworks.sqlite4java.SQLiteConnection;
import com.almworks.sqlite4java.SQLiteException;
import com.almworks.sqlite4java.SQLiteStatement;

/**
* Db
*
* @author     Christoph Kappestein <k42b3.x@gmail.com>
* @license    http://www.gnu.org/licenses/gpl.html GPLv3
* @link       http://code.google.com/p/delta-quadrant
* @version    $Revision: 199 $
*/
public class Db
{
  private static Db instance;

  private SQLiteConnection db;

  private Db() throws SQLiteException
  {
    db = new SQLiteConnection(new File("projects"));
    db.open(true);
  }

  public SQLiteStatement query(String sql) throws SQLiteException
  {
    return db.prepare(sql);
  }

  public void exec(String sql) throws SQLiteException
  {
    db.exec(sql);
  }

  public static Db getInstance() throws SQLiteException
  {
    if(Db.instance == null)
    {
      Db.instance = new Db();
    }

    return Db.instance;
  }
}
TOP

Related Classes of com.k42b3.kadabra.Db

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.