You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mv...@apache.org on 2004/03/02 14:18:31 UTC

cvs commit: jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/model Unique.java

mvdb        2004/03/02 05:18:31

  Modified:    sql/src/java/org/apache/commons/sql/task DatabaseTask.java
               sql/src/java/org/apache/commons/sql/builder SqlBuilder.java
                        PostgreSqlBuilder.java
               sql/src/java/org/apache/commons/sql/model Unique.java
  Log:
  Removed unused imports.
  
  Revision  Changes    Path
  1.3       +132 -133  jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/task/DatabaseTask.java
  
  Index: DatabaseTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/task/DatabaseTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DatabaseTask.java	28 Feb 2004 03:35:48 -0000	1.2
  +++ DatabaseTask.java	2 Mar 2004 13:18:31 -0000	1.3
  @@ -12,137 +12,136 @@
    * 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.commons.sql.task;
  -
  -import java.sql.Connection;
  -import java.sql.DriverManager;
  -import java.sql.SQLException;
  -
  -import javax.sql.DataSource;
  -
  -import org.apache.commons.sql.io.JdbcModelReader;
  -import org.apache.commons.sql.model.Database;
  -import org.apache.commons.sql.util.DataSourceWrapper;
  -import org.apache.tools.ant.BuildException;
  -import org.apache.tools.ant.Task;
  -
  -/**
  - * This is an abstract class for tasks that need to access a database through
  - * a connection.
  - *
  - * @author <a href="mailto:drfish@cox.net">J. Russell Smyth</a>
  - * @author John Marshall/Connectria
  - * @version $Id$
  - */
  -public abstract class DatabaseTask extends Task
  -{
  -    /** JDBC URL. */
  -    protected String dbUrl;
  -
  -    /** JDBC driver. */
  -    protected String dbDriver;
  -
  -    /** JDBC user name. */
  -    protected String dbUser;
  -
  -    /** JDBC password. */
  -    protected String dbPassword;
  -
  -    /** DB catalog to use. */
  -    protected String dbCatalog;
  -
  -    /** DB schema to use. */
  -    protected String dbSchema;
  -
  -    public String getDbSchema()
  -    {
  -        return dbSchema;
  -    }
  -
  -    public void setDbCatalog(String dbCatalog)
  -    {
  -        this.dbCatalog = dbCatalog;
  -    }
  -
  -    public void setDbSchema(String dbSchema)
  -    {
  -        this.dbSchema = dbSchema;
  -    }
  -
  -    public void setDbUrl(String v)
  -    {
  -        dbUrl = v;
  -    }
  -
  -    public String getDbUrl()
  -    {
  -        return dbUrl;
  -    }
  -
  -    public void setDbDriver(String v)
  -    {
  -        dbDriver = v;
  -    }
  -
  -    public void setDbUser(String v)
  -    {
  -        dbUser = v;
  -    }
  -
  -    public void setDbPassword(String v)
  -    {
  -        dbPassword = v;
  -    }
  -
  -    /**
  -     * Prints the connection settings to stderr.
  -     */
  -    protected void printDbSettings() throws BuildException
  -    {
  -        System.err.println("Your DB settings are:");
  -        System.err.println("driver : " + dbDriver);
  -        System.err.println("URL : " + dbUrl);
  -        System.err.println("user : " + dbUser);
  -        System.err.println("password : " + dbPassword);
  -        System.err.println("catalog : " + dbCatalog);
  -        System.err.println("schema : " + dbSchema);
  -    }
  -
  -    /**
  -     * Gets a Connection as specified
  -     * 
  -     * @return a Connection to the database
  -     * 
  -     * @throws ClassNotFoundException if dbDriver cannot be loaded
  -     * @throws SQLException if the database cannot be connected to
  -     */
  -    protected DataSource getDataSource() throws ClassNotFoundException, SQLException
  -    {
  -        // Load the database Driver.
  -        DataSourceWrapper wrapper = new DataSourceWrapper(dbDriver, dbUrl, dbUser, dbPassword);
  -        return wrapper;
  -    }
  -
  -    /**
  -     * Retrievs the database specification from a connection
  -     * @param con The database connection
  -     * @return the Database schema
  -     * 
  -     * @throws SQLException if the schema cannot be read
  -     */
  -    protected Database getDbFromConnection(Connection con) throws SQLException
  -    {
  -        JdbcModelReader reader = new JdbcModelReader(con);
  -        if ( dbCatalog!=null ) {
  -            reader.setCatalog(dbCatalog);
  -        }
  -        if ( dbSchema!=null ) {
  -            reader.setSchema(dbSchema);
  -        }
  -
  -        Database db = reader.getDatabase();
  -        return db;
  -    } 
  + */
  +
  +package org.apache.commons.sql.task;
  +
  +import java.sql.Connection;
  +import java.sql.SQLException;
  +
  +import javax.sql.DataSource;
  +
  +import org.apache.commons.sql.io.JdbcModelReader;
  +import org.apache.commons.sql.model.Database;
  +import org.apache.commons.sql.util.DataSourceWrapper;
  +import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.Task;
  +
  +/**
  + * This is an abstract class for tasks that need to access a database through
  + * a connection.
  + *
  + * @author <a href="mailto:drfish@cox.net">J. Russell Smyth</a>
  + * @author John Marshall/Connectria
  + * @version $Id$
  + */
  +public abstract class DatabaseTask extends Task
  +{
  +    /** JDBC URL. */
  +    protected String dbUrl;
  +
  +    /** JDBC driver. */
  +    protected String dbDriver;
  +
  +    /** JDBC user name. */
  +    protected String dbUser;
  +
  +    /** JDBC password. */
  +    protected String dbPassword;
  +
  +    /** DB catalog to use. */
  +    protected String dbCatalog;
  +
  +    /** DB schema to use. */
  +    protected String dbSchema;
  +
  +    public String getDbSchema()
  +    {
  +        return dbSchema;
  +    }
  +
  +    public void setDbCatalog(String dbCatalog)
  +    {
  +        this.dbCatalog = dbCatalog;
  +    }
  +
  +    public void setDbSchema(String dbSchema)
  +    {
  +        this.dbSchema = dbSchema;
  +    }
  +
  +    public void setDbUrl(String v)
  +    {
  +        dbUrl = v;
  +    }
  +
  +    public String getDbUrl()
  +    {
  +        return dbUrl;
  +    }
  +
  +    public void setDbDriver(String v)
  +    {
  +        dbDriver = v;
  +    }
  +
  +    public void setDbUser(String v)
  +    {
  +        dbUser = v;
  +    }
  +
  +    public void setDbPassword(String v)
  +    {
  +        dbPassword = v;
  +    }
  +
  +    /**
  +     * Prints the connection settings to stderr.
  +     */
  +    protected void printDbSettings() throws BuildException
  +    {
  +        System.err.println("Your DB settings are:");
  +        System.err.println("driver : " + dbDriver);
  +        System.err.println("URL : " + dbUrl);
  +        System.err.println("user : " + dbUser);
  +        System.err.println("password : " + dbPassword);
  +        System.err.println("catalog : " + dbCatalog);
  +        System.err.println("schema : " + dbSchema);
  +    }
  +
  +    /**
  +     * Gets a Connection as specified
  +     * 
  +     * @return a Connection to the database
  +     * 
  +     * @throws ClassNotFoundException if dbDriver cannot be loaded
  +     * @throws SQLException if the database cannot be connected to
  +     */
  +    protected DataSource getDataSource() throws ClassNotFoundException, SQLException
  +    {
  +        // Load the database Driver.
  +        DataSourceWrapper wrapper = new DataSourceWrapper(dbDriver, dbUrl, dbUser, dbPassword);
  +        return wrapper;
  +    }
  +
  +    /**
  +     * Retrievs the database specification from a connection
  +     * @param con The database connection
  +     * @return the Database schema
  +     * 
  +     * @throws SQLException if the schema cannot be read
  +     */
  +    protected Database getDbFromConnection(Connection con) throws SQLException
  +    {
  +        JdbcModelReader reader = new JdbcModelReader(con);
  +        if ( dbCatalog!=null ) {
  +            reader.setCatalog(dbCatalog);
  +        }
  +        if ( dbSchema!=null ) {
  +            reader.setSchema(dbSchema);
  +        }
  +
  +        Database db = reader.getDatabase();
  +        return db;
  +    } 
   }
  
  
  
  1.16      +0 -2      jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/SqlBuilder.java
  
  Index: SqlBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/SqlBuilder.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SqlBuilder.java	28 Feb 2004 03:35:47 -0000	1.15
  +++ SqlBuilder.java	2 Mar 2004 13:18:31 -0000	1.16
  @@ -25,8 +25,6 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.commons.sql.io.JdbcModelReader;
  -import org.apache.commons.sql.model.Index;
  -import org.apache.commons.sql.model.IndexColumn;
   import org.apache.commons.sql.model.Column;
   import org.apache.commons.sql.model.Database;
   import org.apache.commons.sql.model.ForeignKey;
  
  
  
  1.8       +1 -3      jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/PostgreSqlBuilder.java
  
  Index: PostgreSqlBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/PostgreSqlBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PostgreSqlBuilder.java	28 Feb 2004 03:35:47 -0000	1.7
  +++ PostgreSqlBuilder.java	2 Mar 2004 13:18:31 -0000	1.8
  @@ -21,8 +21,6 @@
   import org.apache.commons.sql.model.Column;
   import org.apache.commons.sql.model.Table;
   
  -import java.io.IOException;
  -
   /**
    * An SQL Builder for PostgresSqlL
    * 
  
  
  
  1.3       +41 -43    jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/model/Unique.java
  
  Index: Unique.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/model/Unique.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Unique.java	28 Feb 2004 03:35:48 -0000	1.2
  +++ Unique.java	2 Mar 2004 13:18:31 -0000	1.3
  @@ -12,46 +12,44 @@
    * 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.commons.sql.model;
  -
  -import java.util.Iterator;
  -import java.util.ArrayList;
  -import java.util.List;
  -
  -/**
  - * Provides compatibility with Torque-style xml with separate &lt;index&gt; and
  - * &lt;unique&gt; tags, but adds no functionality.  All indexes are treated the
  - * same by the Table.
  - * 
  - * @author <a href="mailto:jmarshall@connectria.com">John Marshall</a>
  - * @version $Revision$
  - */
  -public class Unique extends Index
  -{
  -    public Unique() {
  -        setUnique( true );
  -    }
  -    
  -    public void setUnique(boolean unique) {
  -        if ( unique == false ) {
  -            throw new IllegalArgumentException( "Unique index cannot be made non-unique" );
  -        }
  -        super.setUnique(unique);
  -    }
  -
  -    public boolean isUnique() {
  -        return true;
  -    }
  -
  -    public void addUniqueColumn(UniqueColumn indexColumn)
  -    {
  -        super.addIndexColumn(indexColumn);
  -    }
  -    
  -    public List getUniqueColumns()
  -    {
  -        return super.getIndexColumns();
  -    }
  -    
  -}
  + */
  +package org.apache.commons.sql.model;
  +
  +import java.util.List;
  +
  +/**
  + * Provides compatibility with Torque-style xml with separate &lt;index&gt; and
  + * &lt;unique&gt; tags, but adds no functionality.  All indexes are treated the
  + * same by the Table.
  + * 
  + * @author <a href="mailto:jmarshall@connectria.com">John Marshall</a>
  + * @version $Revision$
  + */
  +public class Unique extends Index
  +{
  +    public Unique() {
  +        setUnique( true );
  +    }
  +    
  +    public void setUnique(boolean unique) {
  +        if ( unique == false ) {
  +            throw new IllegalArgumentException( "Unique index cannot be made non-unique" );
  +        }
  +        super.setUnique(unique);
  +    }
  +
  +    public boolean isUnique() {
  +        return true;
  +    }
  +
  +    public void addUniqueColumn(UniqueColumn indexColumn)
  +    {
  +        super.addIndexColumn(indexColumn);
  +    }
  +    
  +    public List getUniqueColumns()
  +    {
  +        return super.getIndexColumns();
  +    }
  +    
  +}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org