KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > ddl > DatabaseSpecification


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.ddl;
21
22 import java.sql.*;
23 import java.util.*;
24 import org.netbeans.lib.ddl.*;
25
26 /**
27 * Interface for commands.
28 * DatabaseSpecification instances keeps information about used database type (object was
29 * created using factory's method createSpecification()) and used connection info.
30 * It should be used as factory for DDLCommands.
31 * It also converts java classes into native database types and vice versa.
32 *
33 * @author Slavek Psenicka
34 */

35 public interface DatabaseSpecification {
36
37     /** Returns database metadata */
38     public DatabaseMetaData getMetaData() throws SQLException;
39
40     public String JavaDoc getMetaDataAdaptorClassName();
41     public void setMetaDataAdaptorClassName(String JavaDoc name);
42
43     /** Returns used connection */
44     public DBConnection getConnection();
45
46     /** Creates and returns java.sql.Connection object */
47     public Connection openJDBCConnection() throws DDLException;
48
49     /** Returns java.sql.Connection, if present and open */
50     public Connection getJDBCConnection();
51
52     /** Returns factory */
53     public DatabaseSpecificationFactory getSpecificationFactory();
54
55     /** Sets factory */
56     public void setSpecificationFactory(DatabaseSpecificationFactory fac);
57
58     /** Closes the connection.
59     * If you forget to close the connection, next open should throw
60     * DDLException. This is an internal dummy-trap.
61     */

62     public void closeJDBCConnection() throws DDLException;
63
64     /** Returns all database properties.
65     * It contains all command properties. Used to obtain settings independent
66     * on commands.
67     */

68     public Map getProperties();
69
70     /** Returns properties of command.
71     * This description should be used for formatting commands, it contains
72     * available information for DatabaseSpecification.
73     * @param command Name of command.
74     */

75     public Map getCommandProperties(String JavaDoc command);
76
77     /** Creates command identified by commandName. Command names will include
78     * create/rename/drop table/view/index/column and comment table/column. It
79     * returns null if command specified by commandName was not found. Used
80     * system allows developers to extend db-specification files and simply
81     * address new commands (everybody can implement createXXXCommand()).
82     * @param command Name of command.
83     */

84     public DDLCommand createCommand(String JavaDoc commandName) throws CommandNotSupportedException;
85
86     /** Returns DBType where maps specified java type.
87     */

88     public String JavaDoc getType(int sqltype);
89 }
90
91 /*
92 * <<Log>>
93 * 3 Gandalf 1.2 10/22/99 Ian Formanek NO SEMANTIC CHANGE - Sun
94 * Microsystems Copyright in File Comment
95 * 2 Gandalf 1.1 9/13/99 Slavek Psenicka
96 * 1 Gandalf 1.0 9/10/99 Slavek Psenicka
97 * $
98 */

99
Popular Tags