package honk.tools.anidb;

import java.io.IOException;
import java.sql.SQLException;

public class DBFactory {
    /**
     * Returns a connection to anidb, or null if an error occurs.
     * @return a connection to anidb, or null if an error occurs.
     */
    public static AniDBConnection createConnecton() {
        try {
            return new DBConnection();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
    
    /**
     * Returns a connection to anidb, or null if an error occurs.
     * @return a connection to anidb, or null if an error occurs.
     */
    public static AniDBConnection createWrapper(AniDBConnection db, AniDBConnectionCache cache) {
        return new Wrapper(db, cache);
    }
    
    /**
     * Returns a cache for anidb, or null if an error occurs.
     * @return a cache for anidb, or null if an error occurs.
     */
    public static AniDBConnectionCache createCache() {
        try {
            return new Database();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}
