KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > core > connection > IPentahoConnection


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * Created Aug 26, 2005
14  * @author wseyler
15  */

16
17 package org.pentaho.core.connection;
18
19 import java.util.List JavaDoc;
20 import java.util.Properties JavaDoc;
21
22 /**
23  * A PentahoConnection represents metadata and functions required to execute
24  * queries against data sources. Also contains constants that are properties
25  * in data components <tt>SQLLookupRule</tt>, <tt>MDXLookupRule</tt>.
26  *
27  * @author wseyler
28  *
29  * @see SQLLookupRule
30  * @see MDXLookupRule
31  */

32 public interface IPentahoConnection {
33     /**
34      * Setting for class name used to look up a connection in the pentaho.xml.
35      */

36     public static final String JavaDoc CLASSNAME_KEY = "className"; //$NON-NLS-1$
37
/**
38      * Defines the XML element in the component-definition that holds the
39      * JNDI (Java Naming and Directory Interface) name for the database connection.
40      */

41     public static final String JavaDoc JNDI_NAME_KEY = "jndiName"; //$NON-NLS-1$
42
/**
43      * Defines the XML element in the component-definition that holds the
44      * JDBC Driver
45      */

46     public static final String JavaDoc DRIVER_KEY = "driver"; //$NON-NLS-1$
47
/**
48      * Defines the XML element in the component-definition that holds the
49      * JDBC URL.
50      */

51     public static final String JavaDoc LOCATION_KEY = "location"; //$NON-NLS-1$
52
/**
53      * Defines the XML element in the component-definition that holds the
54      * user name to connect to the JDBC driver
55      */

56     public static final String JavaDoc USERNAME_KEY = "userName"; //$NON-NLS-1$
57
/**
58      * Defines the XML element in the component-definition that holds the
59      * password to connect to the JDBC driver
60      */

61     public static final String JavaDoc PASSWORD_KEY = "password"; //$NON-NLS-1$
62
/**
63      * Defines the XML element in the component-definition that holds the
64      * database query (MDX, SQL, etc).
65      */

66     public static final String JavaDoc QUERY_KEY = "query"; //$NON-NLS-1$
67
/**
68      * Array of the XML element keys defined above.
69      */

70     public static final String JavaDoc[] KEYS = new String JavaDoc[] { CLASSNAME_KEY, JNDI_NAME_KEY, DRIVER_KEY, LOCATION_KEY, USERNAME_KEY, PASSWORD_KEY, QUERY_KEY };
71
72     /**
73      * closes the connection
74      */

75     void close();
76
77     /**
78      * @return the last query string executed
79      */

80     String JavaDoc getLastQuery();
81
82     /**
83      * @param query -
84      * SQL (like) query string. May be datasource specfic
85      * @return result set of the query
86      */

87     IPentahoResultSet executeQuery(String JavaDoc query) throws Exception JavaDoc;
88
89     /**
90      * @param query -
91      * SQL (like) query string. May be datasource specfic
92      * @param parameters - List of objects to bind into prepared query
93      * @return result set of the query
94      */

95     IPentahoResultSet prepareAndExecuteQuery(String JavaDoc query, List JavaDoc parameters) throws Exception JavaDoc;
96     
97     /**
98      * @return true if the connection supports prepared queries
99      */

100     boolean preparedQueriesSupported();
101     
102     /**
103      * @return the last resultset from the last query executed
104      */

105     IPentahoResultSet getResultSet();
106
107     /**
108      * @return true if this connection has been closed
109      */

110     boolean isClosed();
111
112     /**
113      * @return true if this connection is read only
114      *
115      * NOTE: Current implementation for all connections are read only
116      */

117     boolean isReadOnly();
118
119     /**
120      * Clears any warnings cached by the connection
121      */

122     void clearWarnings();
123
124     /**
125      * Connects to the data source using the supplied properties.
126      * @param props Datasource connection properties
127      * @return true if the connection was successful
128      */

129     boolean connect(Properties JavaDoc props);
130
131     /**
132      * The maximum rows that will be returned by the next query
133      * @param maxRows
134      */

135     void setMaxRows(int maxRows);
136
137     /**
138      * Size of the fetch buffer used when retrieving rows from the
139      * underlying database.
140      * @param fetchSize
141      */

142     void setFetchSize(int fetchSize);
143
144     /**
145      * @return true if the connection has been properly initialized.
146      */

147     public boolean initialized();
148 }
149
Popular Tags