001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.lib.ddl;
043:
044: import java.sql.*;
045: import java.util.*;
046: import org.netbeans.lib.ddl.*;
047:
048: /**
049: * Interface for commands.
050: * DatabaseSpecification instances keeps information about used database type (object was
051: * created using factory's method createSpecification()) and used connection info.
052: * It should be used as factory for DDLCommands.
053: * It also converts java classes into native database types and vice versa.
054: *
055: * @author Slavek Psenicka
056: */
057: public interface DatabaseSpecification {
058:
059: /** Returns database metadata */
060: public DatabaseMetaData getMetaData() throws SQLException;
061:
062: public String getMetaDataAdaptorClassName();
063:
064: public void setMetaDataAdaptorClassName(String name);
065:
066: /** Returns used connection */
067: public DBConnection getConnection();
068:
069: /** Creates and returns java.sql.Connection object */
070: public Connection openJDBCConnection() throws DDLException;
071:
072: /** Returns java.sql.Connection, if present and open */
073: public Connection getJDBCConnection();
074:
075: /** Returns factory */
076: public DatabaseSpecificationFactory getSpecificationFactory();
077:
078: /** Sets factory */
079: public void setSpecificationFactory(DatabaseSpecificationFactory fac);
080:
081: /** Closes the connection.
082: * If you forget to close the connection, next open should throw
083: * DDLException. This is an internal dummy-trap.
084: */
085: public void closeJDBCConnection() throws DDLException;
086:
087: /** Returns all database properties.
088: * It contains all command properties. Used to obtain settings independent
089: * on commands.
090: */
091: public Map getProperties();
092:
093: /** Returns properties of command.
094: * This description should be used for formatting commands, it contains
095: * available information for DatabaseSpecification.
096: * @param command Name of command.
097: */
098: public Map getCommandProperties(String command);
099:
100: /** Creates command identified by commandName. Command names will include
101: * create/rename/drop table/view/index/column and comment table/column. It
102: * returns null if command specified by commandName was not found. Used
103: * system allows developers to extend db-specification files and simply
104: * address new commands (everybody can implement createXXXCommand()).
105: * @param command Name of command.
106: */
107: public DDLCommand createCommand(String commandName)
108: throws CommandNotSupportedException;
109:
110: /** Returns DBType where maps specified java type.
111: */
112: public String getType(int sqltype);
113: }
114:
115: /*
116: * <<Log>>
117: * 3 Gandalf 1.2 10/22/99 Ian Formanek NO SEMANTIC CHANGE - Sun
118: * Microsystems Copyright in File Comment
119: * 2 Gandalf 1.1 9/13/99 Slavek Psenicka
120: * 1 Gandalf 1.0 9/10/99 Slavek Psenicka
121: * $
122: */
|