001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.db;
020
021import lucee.runtime.PageContext;
022import lucee.runtime.exp.PageException;
023
024public interface DataSourceManager {
025
026        /**
027         * return a database connection matching to datsource name 
028         * @param datasource datasource whished
029         * @param user username to datasource
030         * @param pass password to datasource
031         * @return return a Db Connectio9n Object
032         * @throws PageException 
033         * @deprecated use instead <code>getConnection(PageContext pc,DataSource ds, String user, String pass)</code>
034         */
035        public DatasourceConnection getConnection(PageContext pc,String datasource,
036                        String user, String pass) throws PageException;
037        
038        /**
039         * return a database connection matching to datsource name 
040         * @param ds datasource whished
041         * @param user username to datasource
042         * @param pass password to datasource
043         * @return return a Db Connectio9n Object
044         * @throws PageException 
045         */
046        public DatasourceConnection getConnection(PageContext pc,DataSource ds, String user, String pass) throws PageException;
047        
048        
049        public abstract void releaseConnection(PageContext pc,DatasourceConnection dc) throws PageException;
050
051        /**
052         * set state of transaction to begin
053         */
054        public abstract void begin();
055
056        /**
057         * set state of transaction to begin
058         * @param isolation isolation level of the transaction
059         */
060        public abstract void begin(String isolation);
061
062        /**
063         * set state of transaction to begin
064         * @param isolation isolation level of the transaction
065         */
066        public abstract void begin(int isolation);
067
068        /**
069         * rollback hanging transaction
070         * @throws DatabaseException
071         */
072        public abstract void rollback() throws PageException;
073        
074        public abstract void savepoint() throws PageException;
075
076        /**
077         * commit hanging transaction
078         * @throws DatabaseException
079         */
080        public abstract void commit() throws PageException;
081
082        /**
083         * @return return if manager is in autocommit mode or not
084         */
085        public abstract boolean isAutoCommit();
086
087        /**
088         * ends the manual commit state
089         */
090        public abstract void end();
091
092        public abstract void remove(String datasource);// FUTURE deprecated
093        //FUTURE public abstract void remove(DataSource datasource);
094
095        public abstract void release();
096
097}