1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.log4j.db;
19
20 import org.apache.log4j.spi.Component;
21 import org.apache.log4j.spi.OptionHandler;
22
23 import java.sql.Connection;
24 import java.sql.SQLException;
25
26
27 /**
28 * The {@code ConnectionSource} interface provides a pluggable means of
29 * transparently obtaining JDBC {@link java.sql.Connection}s for log4j classes
30 * that require the use of a {@link java.sql.Connection}.
31 *
32 * @author <a href="mailto:rdecampo@twcny.rr.com">Ray DeCampo</a>
33 */
34 public interface ConnectionSource extends Component, OptionHandler {
35
36 final int UNKNOWN_DIALECT = 0;
37 final int POSTGRES_DIALECT = 1;
38 final int MYSQL_DIALECT = 2;
39 final int ORACLE_DIALECT = 3;
40 final int MSSQL_DIALECT = 4;
41 final int HSQL_DIALECT = 5;
42 /**
43 * Obtain a {@link java.sql.Connection} for use. The client is
44 * responsible for closing the {@link java.sql.Connection} when it is no
45 * longer required.
46 *
47 * @throws SQLException if a {@link java.sql.Connection} could not be
48 * obtained
49 */
50 Connection getConnection() throws SQLException;
51
52 /**
53 * Get the SQL dialect that should be used for this connection. Note that the
54 * dialect is not needed if the JDBC driver supports the getGeneratedKeys
55 * method.
56 */
57 int getSQLDialectCode();
58
59 /**
60 * If the connection supports the JDBC 3.0 getGeneratedKeys method, then
61 * we do not need any specific dialect support.
62 */
63 boolean supportsGetGeneratedKeys();
64
65 /**
66 * If the connection does not support batch updates, we will avoid using them.
67 */
68 public boolean supportsBatchUpdates();
69 }