View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
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 de.smartics.properties.spi.config.ds;
17  
18  import java.io.Serializable;
19  import java.sql.PreparedStatement;
20  import java.sql.SQLException;
21  
22  import javax.sql.DataSource;
23  
24  /**
25   * Allows serializable access to a data source.
26   */
27  public interface DataSourceProxy extends Serializable
28  {
29    // ********************************* Fields *********************************
30  
31    // --- constants ------------------------------------------------------------
32  
33    // ****************************** Initializer *******************************
34  
35    // ****************************** Inner Classes *****************************
36  
37    // ********************************* Methods ********************************
38  
39    // --- get&set --------------------------------------------------------------
40  
41    /**
42     * Returns the identifier of the data source.
43     *
44     * @return the identifier of the data source.
45     */
46    String getDataSourceId();
47  
48    /**
49     * Provides access to the data source.
50     *
51     * @return the data source.
52     */
53    DataSource getDataSource();
54  
55    /**
56     * Provides an SQL template to create the configuration table.
57     *
58     * @return the SQL template to create the configuration table.
59     */
60    String getCreateTableSqlTemplate();
61  
62    /**
63     * Provides an SQL template to insert or update a value in the configuration
64     * table.
65     *
66     * @return the SQL template to insert or update a value in the configuration
67     *         table.
68     */
69    String getInsertOrUpdateSqlTemplate();
70  
71    /**
72     * Sets the parameters to the given statement to insert or update a property
73     * in the configuration table.
74     * <p>
75     * The statement ist provided by {@link #getInsertOrUpdateSqlTemplate()}.
76     * </p>
77     *
78     * @param statement the statement to set the values.
79     * @param config the configuration key.
80     * @param name the property key.
81     * @param value the property value.
82     * @throws SQLException on any problem configuring the given {@code statement}.
83     */
84    void setInsertOrUpdate(PreparedStatement statement, String config,
85        String name, String value) throws SQLException;
86  
87    // --- business -------------------------------------------------------------
88  
89    // --- object basics --------------------------------------------------------
90  
91  }