db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1213046 - /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/
Date Sun, 11 Dec 2011 19:32:22 GMT
Author: tfischer
Date: Sun Dec 11 19:32:22 2011
New Revision: 1213046

URL: http://svn.apache.org/viewvc?rev=1213046&view=rev
Log:
TORQUE-174: Remove adapters which are not supported any more

Removed:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBAxion.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBCloudscape.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBDB2400.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBDB2App.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBDB2Net.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFirebird.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBInformix.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBInstantDB.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBInterbase.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBOdbc.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBSapDB.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBSybase.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBWeblogic.java
Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractDBAdapter.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBMSSQL.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractDBAdapter.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractDBAdapter.java?rev=1213046&r1=1213045&r2=1213046&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractDBAdapter.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractDBAdapter.java
Sun Dec 11 19:32:22 2011
@@ -66,6 +66,9 @@ import org.apache.torque.util.functions.
  */
 public abstract class AbstractDBAdapter implements DB
 {
+    /** Serial version UID. */
+    private static final long serialVersionUID = 1L;
+
     /**
      * The default look up table for function classes.
      */

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java?rev=1213046&r1=1213045&r2=1213046&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBFactory.java
Sun Dec 11 19:32:22 2011
@@ -56,71 +56,33 @@ public final class DBFactory
      */
     static
     {
-        adapters.put("com.ibm.as400.access.AS400JDBCDriver", DBDB2400.class);
-        adapters.put("COM.ibm.db2.jdbc.app.DB2Driver", DBDB2App.class);
-        adapters.put("COM.ibm.db2.jdbc.net.DB2Driver", DBDB2Net.class);
-        adapters.put("COM.cloudscape.core.JDBCDriver", DBCloudscape.class);
-        adapters.put("org.firebirdsql.jdbc.FBDriver", DBFirebird.class);
         adapters.put("org.hsql.jdbcDriver", DBHsqldb.class);
         adapters.put("org.hsqldb.jdbcDriver", DBHsqldb.class);
-        adapters.put("interbase.interclient.Driver", DBInterbase.class);
-        adapters.put("org.enhydra.instantdb.jdbc.idbDriver", DBInstantDB.class);
         adapters.put("com.microsoft.jdbc.sqlserver.SQLServerDriver",
             DBMSSQL.class);
         adapters.put("com.jnetdirect.jsql.JSQLDriver", DBMSSQL.class);
         adapters.put("org.gjt.mm.mysql.Driver", DBMM.class);
         adapters.put("oracle.jdbc.driver.OracleDriver", DBOracle.class);
         adapters.put("org.postgresql.Driver", DBPostgres.class);
-        adapters.put("com.sap.dbtech.jdbc.DriverSapDB", DBSapDB.class);
-        adapters.put("com.sybase.jdbc.SybDriver", DBSybase.class);
-        adapters.put("com.sybase.jdbc2.jdbc.SybDriver", DBSybase.class);
-        adapters.put("weblogic.jdbc.pool.Driver", DBWeblogic.class);
-        adapters.put("org.axiondb.jdbc.AxionDriver", DBAxion.class);
-        adapters.put("com.informix.jdbc.IfxDriver", DBInformix.class);
-        adapters.put("sun.jdbc.odbc.JdbcOdbcDriver", DBOdbc.class);
 
-        adapters.put("com.ibm.db2.jcc.DB2Driver", DBDerby.class);
         adapters.put("org.apache.derby.jdbc.EmbeddedDriver", DBDerby.class);
 
 
         // add some short names to be used when drivers are not used
-        adapters.put("as400", DBDB2400.class);
-        adapters.put("db2app", DBDB2App.class);
-        adapters.put("db2net", DBDB2Net.class);
-        adapters.put("cloudscape", DBCloudscape.class);
-        adapters.put("firebird", DBFirebird.class);
         adapters.put("hsqldb", DBHsqldb.class);
-        adapters.put("interbase", DBInterbase.class);
-        adapters.put("instantdb", DBInstantDB.class);
         adapters.put("mssql", DBMSSQL.class);
         adapters.put("mysql", DBMM.class);
         adapters.put("oracle", DBOracle.class);
         adapters.put("postgresql", DBPostgres.class);
-        adapters.put("sapdb", DBSapDB.class);
-        adapters.put("sybase", DBSybase.class);
-        adapters.put("weblogic", DBWeblogic.class);
-        adapters.put("axion", DBAxion.class);
-        adapters.put("informix", DBInformix.class);
-        adapters.put("odbc", DBOdbc.class);
-        adapters.put("msaccess", DBOdbc.class);
         adapters.put("derby", DBDerby.class);
 
         // add database product names to be used for auto-detection
-        adapters.put("DB2/NT", DBDB2App.class);
-        adapters.put("DB2/LINUX", DBDB2App.class);
-        adapters.put("DB2/6000", DBDB2App.class);
-        adapters.put("DB2/HPUX", DBDB2App.class);
-        adapters.put("DB2/SUN", DBDB2App.class);
-        adapters.put("DB2/LINUX390", DBDB2App.class);
-        adapters.put("DB2/AIX64", DBDB2App.class);
         adapters.put("HSQL Database Engine", DBHsqldb.class);
         adapters.put("Microsoft SQL Server Database", DBMSSQL.class);
         adapters.put("Microsoft SQL Server", DBMSSQL.class);
         adapters.put("MySQL", DBMM.class);
         adapters.put("Oracle", DBOracle.class);
         adapters.put("PostgreSQL", DBPostgres.class);
-        adapters.put("Sybase SQL Server", DBSybase.class);
-        adapters.put("Informix Dynamic Server", DBInformix.class);
         adapters.put("Apache Derby", DBDerby.class);
 
         adapters.put("", DBNone.class);

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBMSSQL.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBMSSQL.java?rev=1213046&r1=1213045&r2=1213046&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBMSSQL.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DBMSSQL.java
Sun Dec 11 19:32:22 2011
@@ -19,28 +19,203 @@ package org.apache.torque.adapter;
  * under the License.
  */
 
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.torque.TorqueException;
+import org.apache.torque.sql.Query;
+
 /**
- * This is used to connect to a MSSQL database.  For now, this class
- * simply extends the adaptor for Sybase.  You can use one of several
- * commercial JDBC drivers; the one I use is:
- *
- *   i-net SPRINTA(tm) 2000 Driver Version 3.03 for MS SQL Server
- *   http://www.inetsoftware.de/
+ * This is used to connect to a MSSQL database.
+ * This is tested with the jtds driver from sourceforge.
  *
  * @author <a href="mailto:gonzalo.diethelm@sonda.com">Gonzalo Diethelm</a>
  * @version $Id$
  */
-public class DBMSSQL extends DBSybase
+public class DBMSSQL extends AbstractDBAdapter
 {
     /**
      * Serial version
      */
     private static final long serialVersionUID = -2924485528975497044L;
 
+    /** date format */
+    private static final String DATE_FORMAT = "yyyyMMdd HH:mm:ss";
+
     /**
      * Empty constructor.
      */
     protected DBMSSQL()
     {
     }
+
+    /**
+     * This method is used to ignore case.
+     *
+     * @param in The string to transform to upper case.
+     * @return The upper case string.
+     */
+    public String toUpperCase(String in)
+    {
+        return new StringBuffer("UPPER(").append(in).append(")").toString();
+    }
+
+    /**
+     * This method is used to ignore case.
+     *
+     * @param in The string whose case to ignore.
+     * @return The string in a case that can be ignored.
+     */
+    public String ignoreCase(String in)
+    {
+        return new StringBuffer("UPPER(").append(in).append(")").toString();
+    }
+
+    /**
+     * @see org.apache.torque.adapter.DB#getIDMethodType()
+     */
+    public String getIDMethodType()
+    {
+        return AUTO_INCREMENT;
+    }
+
+    /**
+     * Returns the last value from an identity column (available on a
+     * per-session basis from the global variable
+     * <code>@@identity</code>).
+     *
+     * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
+     */
+    public String getIDMethodSQL(Object unused)
+    {
+        return "select @@identity";
+    }
+
+    /**
+     * Locks the specified table.
+     *
+     * @param con The JDBC connection to use.
+     * @param table The name of the table to lock.
+     * @throws SQLException No Statement could be created or executed.
+     */
+    public void lockTable(Connection con, String table) throws SQLException
+    {
+        Statement statement = con.createStatement();
+
+        StringBuffer stmt = new StringBuffer();
+        stmt.append("SELECT next_id FROM ")
+        .append(table)
+        .append(" FOR UPDATE");
+
+        statement.executeQuery(stmt.toString());
+    }
+
+    /**
+     * Unlocks the specified table.
+     *
+     * @param con The JDBC connection to use.
+     * @param table The name of the table to unlock.
+     * @throws SQLException No Statement could be created or executed.
+     */
+    public void unlockTable(Connection con, String table) throws SQLException
+    {
+        // Tables in Sybase are unlocked when a commit is issued.  The
+        // user may have issued a commit but do it here to be sure.
+        con.commit();
+    }
+
+    /**
+     * This method is used to chek whether the database supports
+     * limiting the size of the resultset.
+     *
+     * @return LIMIT_STYLE_SYBASE.
+     * @deprecated This should not be exposed to the outside
+     */
+    public int getLimitStyle()
+    {
+        return DB.LIMIT_STYLE_SYBASE;
+    }
+
+    /**
+     * Return true for Sybase
+     * @see org.apache.torque.adapter.AbstractDBAdapter#supportsNativeLimit()
+     */
+    public boolean supportsNativeLimit()
+    {
+        return true;
+    }
+
+    /**
+     * Modify a query to add limit and offset values for Sybase.
+     *
+     * @param query The query to modify
+     * @param offset the offset Value
+     * @param limit the limit Value
+     *
+     * @throws TorqueException if any error occurs when building the query
+     */
+    public void generateLimits(Query query, int offset, int limit)
+        throws TorqueException
+    {
+        if (limit < 0 && offset >= 0) // Offset only test
+        {
+            return;
+        }
+        if (limit + offset > 0)
+        {
+            query.setRowcount(String.valueOf(limit + offset));
+        }
+        else if (limit + offset == 0)
+        {
+            // This is necessary to create the empty result set that Torque expects
+            query.getWhereClause().add("1=0");
+        }
+    }
+
+    /**
+     * This method overrides the JDBC escapes used to format dates
+     * using a <code>DateFormat</code>.  As of version 11, the Sybase
+     * JDBC driver does not implement JDBC 3.0 escapes.
+     *
+     * @param date the date to format
+     * @return The properly formatted date String.
+     */
+    public String getDateString(Date date)
+    {
+        char delim = getStringDelimiter();
+        return (delim + new SimpleDateFormat(DATE_FORMAT).format(date) + delim);
+    }
+
+    /**
+     * Determines whether backslashes (\) should be escaped in explicit SQL
+     * strings. If true is returned, a BACKSLASH will be changed to "\\".
+     * If false is returned, a BACKSLASH will be left as "\".
+     *
+     * Sybase (and MSSQL) doesn't define a default escape character,
+     * so false is returned.
+     *
+     * @return false
+     * @see org.apache.torque.adapter.DB#escapeText()
+     */
+    public boolean escapeText()
+    {
+        return false;
+    }
+
+    /**
+     * Whether an escape clause in like should be used.
+     * Example : select * from AUTHOR where AUTHOR.NAME like '\_%' ESCAPE '\';
+     *
+     * Sybase needs this, so this implementation always returns
+     * <code>true</code>.
+     *
+     * @return whether the escape clause should be appended or not.
+     */
+    public boolean useEscapeClauseForLike()
+    {
+        return true;
+    }
 }



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


Mime
View raw message