001 package org.apache.ojb.broker.util.dbhandling;
002
003 /* Copyright 2004-2005 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 import java.io.IOException;
019 import java.io.InputStream;
020 import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
021 import org.apache.ojb.broker.platforms.PlatformException;
022
023 /**
024 * Interface for classes providing basic database handling (drop, create, init).
025 *
026 * @author Thomas Dudziak
027 */
028 public interface DBHandling
029 {
030 /**
031 * Sets the working directory.
032 *
033 * @param dir The directory
034 * @throws IOException If the directory does not exist or cannot be written/read
035 */
036 public void setWorkDir(String dir) throws IOException;
037
038 /**
039 * Sets the jdbc connection to use.
040 *
041 * @param jcd The connection to use
042 * @throws PlatformException If the target database cannot be handled
043 */
044 public void setConnection(JdbcConnectionDescriptor jcd) throws PlatformException;
045
046 /**
047 * Returns the connection descriptor used by this handling object.
048 *
049 * @return The connection descriptor
050 */
051 public JdbcConnectionDescriptor getConnection();
052
053 /**
054 * Adds db definition files to use.
055 *
056 * @param srcDir The directory containing the files
057 * @param listOfFilenames The filenames in a comma-separated list
058 */
059 public void addDBDefinitionFiles(String srcDir, String listOfFilenames) throws IOException;
060
061 /**
062 * Adds an input streams containg part of the db definition to use.
063 *
064 * @param schemataStreams Input streams
065 */
066 public void addDBDefinitionFile(InputStream inputStream) throws IOException;
067
068 /**
069 * Creates the database.
070 *
071 * @throws PlatformException If some error occurred
072 */
073 public void createDB() throws PlatformException;
074
075 /**
076 * Creates the tables according to the schema files.
077 *
078 * @throws PlatformException If some error occurred
079 */
080 public void initDB() throws PlatformException;
081 }