db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r169495 - in /incubator/derby/code/branches/datasource: ./ src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/derby/ src/java/org/apache/derby/api/ src/java/org/apache/derby/impl/
Date Tue, 10 May 2005 16:47:54 GMT
Author: jboynes
Date: Tue May 10 09:47:53 2005
New Revision: 169495

URL: http://svn.apache.org/viewcvs?rev=169495&view=rev
Log:
strawman for a unified datasource api

Added:
    incubator/derby/code/branches/datasource/   (with props)
    incubator/derby/code/branches/datasource/project.properties   (with props)
    incubator/derby/code/branches/datasource/project.xml   (with props)
    incubator/derby/code/branches/datasource/src/
    incubator/derby/code/branches/datasource/src/java/
    incubator/derby/code/branches/datasource/src/java/org/
    incubator/derby/code/branches/datasource/src/java/org/apache/
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/BasicDataSource.java
  (with props)
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDataSource.java
  (with props)
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDriver.java
  (with props)
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/PooledDataSource.java
  (with props)
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceFactory.java
  (with props)
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceableDataSource.java
  (with props)
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/XADataSource.java
  (with props)
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/impl/
    incubator/derby/code/branches/datasource/src/java/org/apache/derby/impl/ConnectionFactory.java
  (with props)

Propchange: incubator/derby/code/branches/datasource/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 10 09:47:53 2005
@@ -0,0 +1,8 @@
+*.iml
+*.ipr
+*.iws
+.project
+.classpath
+maven.log
+junit*.properties
+target

Added: incubator/derby/code/branches/datasource/project.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/project.properties?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/project.properties (added)
+++ incubator/derby/code/branches/datasource/project.properties Tue May 10 09:47:53 2005
@@ -0,0 +1,21 @@
+#    Copyright 2004 The Apache Software Foundation
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+
+##
+## $Rev$ $Date$
+##
+
+maven.compile.source=1.3
+maven.compile.target=1.3
+

Propchange: incubator/derby/code/branches/datasource/project.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/derby/code/branches/datasource/project.xml
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/project.xml?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/project.xml (added)
+++ incubator/derby/code/branches/datasource/project.xml Tue May 10 09:47:53 2005
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2003-2004 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+
+<!-- $Rev$ $Date$ -->
+
+<!--
+    Default Project Object Model used to set project wide properties.
+    Should be included in each module using
+    <extend>../../etc/project.xml</extend>
+-->
+<project>
+    <pomVersion>3</pomVersion>
+    <name>Apache Derby</name>
+    <id>derby</id>
+    <groupId>derby</groupId>
+
+    <currentVersion>10.1.0.SNAPSHOT</currentVersion>
+
+    <build>
+        <sourceDirectory>${basedir}/src/java</sourceDirectory>
+        <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
+        <resources>
+            <resource>
+                <directory>${basedir}/src/java</directory>
+                <includes>
+                    <include>**/*.properties</include>
+                </includes>
+            </resource>
+        </resources>
+    </build>
+</project>

Propchange: incubator/derby/code/branches/datasource/project.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/BasicDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/BasicDataSource.java?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/BasicDataSource.java
(added)
+++ incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/BasicDataSource.java
Tue May 10 09:47:53 2005
@@ -0,0 +1,179 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.derby.api;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+
+/**
+ * Base class for {@link javax.sql.DataSource} implementations that defines the appropriate
properties.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BasicDataSource implements Serializable {
+    // standard properties per the JDBC 3.0 specification
+    private String databaseName;
+    private String dataSourceName;
+    private String description;
+    private String networkProtocol;
+    private String password;
+    private int portNumber;
+    private String roleName;
+    private String serverName;
+    private String user;
+
+    // transient properties defined by the DataSource interface
+    private transient int loginTimeout;
+    private transient PrintWriter logWriter;
+
+    // Derby specific properties
+    private boolean createDatabase;
+    private boolean upgrade;
+    private boolean shutdownDatabase;
+
+    public String getDatabaseName() {
+        return databaseName;
+    }
+
+    public void setDatabaseName(String databaseName) {
+        this.databaseName = databaseName;
+    }
+
+    public String getDataSourceName() {
+        return dataSourceName;
+    }
+
+    public void setDataSourceName(String dataSourceName) {
+        this.dataSourceName = dataSourceName;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getNetworkProtocol() {
+        return networkProtocol;
+    }
+
+    public void setNetworkProtocol(String networkProtocol) {
+        this.networkProtocol = networkProtocol;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public int getPortNumber() {
+        return portNumber;
+    }
+
+    public void setPortNumber(int portNumber) {
+        this.portNumber = portNumber;
+    }
+
+    public String getRoleName() {
+        return roleName;
+    }
+
+    public void setRoleName(String roleName) {
+        this.roleName = roleName;
+    }
+
+    public String getServerName() {
+        return serverName;
+    }
+
+    public void setServerName(String serverName) {
+        this.serverName = serverName;
+    }
+
+    public String getUser() {
+        return user;
+    }
+
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    public int getLoginTimeout() {
+        return loginTimeout;
+    }
+
+    public void setLoginTimeout(int loginTimeout) {
+        this.loginTimeout = loginTimeout;
+    }
+
+    public PrintWriter getLogWriter() {
+        return logWriter;
+    }
+
+    public void setLogWriter(PrintWriter logWriter) {
+        this.logWriter = logWriter;
+    }
+
+    public boolean getCreateDatabase() {
+        return createDatabase;
+    }
+
+    public void setCreateDatabase(boolean createDatabase) {
+        this.createDatabase = createDatabase;
+    }
+
+    public boolean getUpgrade() {
+        return upgrade;
+    }
+
+    public void setUpgrade(boolean upgrade) {
+        this.upgrade = upgrade;
+    }
+
+    public boolean getShutdownDatabase() {
+        return shutdownDatabase;
+    }
+
+    public void setShutdownDatabase(boolean shutdownDatabase) {
+        this.shutdownDatabase = shutdownDatabase;
+    }
+
+    /**
+     * Calculate hashCode based on the following properties: <ul> <li>TBD</li>
</ul>
+     *
+     * @return hashCode for this DataSource
+     */
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    /**
+     * Calculate equals based on the following properties: <ul> <li>TBD</li>
</ul>
+     *
+     * @param obj object to compare to
+     *
+     * @return true if both objects refer to the same DataSource
+     */
+    public boolean equals(Object obj) {
+        return super.equals(obj);
+    }
+}

Propchange: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/BasicDataSource.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDataSource.java?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDataSource.java
(added)
+++ incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDataSource.java
Tue May 10 09:47:53 2005
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.derby.api;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import javax.sql.DataSource;
+
+import org.apache.derby.impl.ConnectionFactory;
+
+/**
+ * Main implementation of DataSource intended for use by end user applications.
+ * <p/>
+ * This DataSource can be used by both J2SE and CDC/FP/JSR-169 applications to directly establish
a physical connection
+ * to the database.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DerbyDataSource extends BasicDataSource implements DataSource {
+    public Connection getConnection() throws SQLException {
+        return ConnectionFactory.getInstance().getConnection(this);
+    }
+
+    public Connection getConnection(String username, String password) throws SQLException
{
+        return ConnectionFactory.getInstance().getConnection(this, username, password);
+    }
+}

Propchange: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDataSource.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDriver.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDriver.java?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDriver.java
(added)
+++ incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDriver.java
Tue May 10 09:47:53 2005
@@ -0,0 +1,76 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.derby.api;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * Implementation of legacy JDBC Driver.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DerbyDriver implements Driver {
+    static {
+        DerbyDriver driver = new DerbyDriver();
+        try {
+            DriverManager.registerDriver(driver);
+        } catch (SQLException e) {
+            // ah well
+        }
+    }
+
+    public boolean acceptsURL(String url) throws SQLException {
+        return url.startsWith("jdbc:derby:") || url.equals("jdbc:default:connection");
+    }
+
+    public Connection connect(String url, Properties info) throws SQLException {
+        DriverDataSource ds = new DriverDataSource();
+        // decompose url and properties to initialize the DriverDataSource
+        return ds.getConnection();
+    }
+
+    public int getMajorVersion() {
+        throw new UnsupportedOperationException();
+    }
+
+    public int getMinorVersion() {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean jdbcCompliant() {
+        throw new UnsupportedOperationException();
+    }
+
+    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
{
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Internal implementation of a DataSource that, for compatibility with base JDBC 2.0,
does not implement the actual
+     * interface.
+     */
+    private static class DriverDataSource extends BasicDataSource {
+        private Connection getConnection() throws SQLException {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

Propchange: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/DerbyDriver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/PooledDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/PooledDataSource.java?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/PooledDataSource.java
(added)
+++ incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/PooledDataSource.java
Tue May 10 09:47:53 2005
@@ -0,0 +1,44 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.derby.api;
+
+import java.sql.SQLException;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.sql.ConnectionPoolDataSource;
+import javax.sql.PooledConnection;
+
+/**
+ * Implementation of a DataSource supporting pooled connections. This is intended for use
by connection pooling
+ * middleware rather than end user applications. As such, we assume that javax.naming is
available.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PooledDataSource extends BasicDataSource implements ConnectionPoolDataSource,
Referenceable {
+    public PooledConnection getPooledConnection() throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public PooledConnection getPooledConnection(String user, String password) throws SQLException
{
+        throw new UnsupportedOperationException();
+    }
+
+    public Reference getReference() throws NamingException {
+        return ReferenceFactory.getReference(this);
+    }
+}

Propchange: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/PooledDataSource.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceFactory.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceFactory.java?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceFactory.java
(added)
+++ incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceFactory.java
Tue May 10 09:47:53 2005
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.derby.api;
+
+import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+
+/**
+ * Factory for converting DataSource implementations to and from JNDI Reference implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class ReferenceFactory implements ObjectFactory {
+    static Reference getReference(BasicDataSource ds) throws NamingException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment)
throws Exception {
+        throw new UnsupportedOperationException();
+    }
+}

Propchange: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceableDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceableDataSource.java?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceableDataSource.java
(added)
+++ incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceableDataSource.java
Tue May 10 09:47:53 2005
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.derby.api;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+
+/**
+ * Specialization of DerbyDataSource that can be bound to JNDI as a Reference. This is intended
for use by application
+ * server implementations that actually perform the bind into the directory rather than end
user applications that would
+ * just retrieve a DataSource.
+ * <p/>
+ * This functionality should not be added to the base class as the javax.naming package may
not be available on all
+ * platforms specifically J2ME CDC/FP.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceableDataSource extends DerbyDataSource implements Referenceable {
+    public Reference getReference() throws NamingException {
+        return ReferenceFactory.getReference(this);
+    }
+}

Propchange: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/ReferenceableDataSource.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/XADataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/XADataSource.java?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/XADataSource.java
(added)
+++ incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/XADataSource.java
Tue May 10 09:47:53 2005
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.derby.api;
+
+import java.sql.SQLException;
+import javax.sql.XAConnection;
+
+/**
+ * Implementation of a DataSource supporting XA connections; this is intended for use by
distributed transaction
+ * managers rather than end user applications.
+ *
+ * @version $Rev$ $Date$
+ */
+public class XADataSource extends BasicDataSource implements javax.sql.XADataSource {
+    public XAConnection getXAConnection() throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public XAConnection getXAConnection(String user, String password) throws SQLException
{
+        throw new UnsupportedOperationException();
+    }
+}

Propchange: incubator/derby/code/branches/datasource/src/java/org/apache/derby/api/XADataSource.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/derby/code/branches/datasource/src/java/org/apache/derby/impl/ConnectionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/datasource/src/java/org/apache/derby/impl/ConnectionFactory.java?rev=169495&view=auto
==============================================================================
--- incubator/derby/code/branches/datasource/src/java/org/apache/derby/impl/ConnectionFactory.java
(added)
+++ incubator/derby/code/branches/datasource/src/java/org/apache/derby/impl/ConnectionFactory.java
Tue May 10 09:47:53 2005
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.derby.impl;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.apache.derby.api.BasicDataSource;
+
+/**
+ * Base class for factories that create Connections. Different factory implementations support
different JDBC
+ * specification versions as determined by the JVM in use. Initial support is provided for
the JDBC 2.0, JDBC 3.0 and
+ * JSR-169 APIs.
+ * <p/>
+ * Each subclass is responsible for creating connections as specified by the properties supplied
in the DataSource.
+ * These may be direct connections to an embedded engine, client connections to a remote
server, or other transports as
+ * they become supported.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ConnectionFactory {
+    public static ConnectionFactory getInstance() {
+        // return the appropriate factory for JDBC 2.0, JDBC 3.0 or JSR-169 implementations
of Connection
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Return a physical connection to the database specified by the DataSource.
+     *
+     * @param ds the DataSource to connect to
+     *
+     * @return a physical connection to the database
+     *
+     * @throws SQLException if there was a problem establishing the connection
+     */
+    public abstract Connection getConnection(BasicDataSource ds) throws SQLException;
+
+    /**
+     * Return a physical connection to the database specified by the DataSource.
+     *
+     * @param ds       the DataSource to connect to
+     * @param user     the username to connect with
+     * @param password the password to connect with
+     *
+     * @return a physical connection to the database
+     *
+     * @throws SQLException if there was a problem establishing the connection
+     */
+    public abstract Connection getConnection(BasicDataSource ds, String user, String password)
throws SQLException;
+}

Propchange: incubator/derby/code/branches/datasource/src/java/org/apache/derby/impl/ConnectionFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message