1 /* 2 * Copyright 2013 University of Glasgow. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package broadwick.data; 17 18 import java.sql.Connection; 19 import java.sql.SQLException; 20 import org.jooq.SQLDialect; 21 22 /** 23 * Interface defining the database implementations. 24 */ 25 public interface DatabaseImpl extends java.lang.AutoCloseable { 26 27 /** 28 * Open the database for connection. 29 * @param dbName the name of the database to open/connect. 30 */ 31 void open(final String dbName); 32 33 /** 34 * Close the database connection. 35 */ 36 @Override 37 void close(); 38 39 /** 40 * Get a connection to the database. 41 * @return the connection object. 42 * @throws SQLException if the connection cannot be obtained. 43 */ 44 Connection getConnection() throws SQLException ; 45 46 /** 47 * Obtain the database dialect e.g. SQLDialect.MYSQL or SQLDialect.H2. 48 * @return the SQLDialect of the database. 49 */ 50 SQLDialect getDialect(); 51 52 }