cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 18547] New: - AbstractEsqlConnection: fix for Sybase ASE
Date Tue, 01 Apr 2003 04:45:08 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18547>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18547

AbstractEsqlConnection: fix for Sybase ASE

           Summary: AbstractEsqlConnection: fix for Sybase ASE
           Product: Cocoon 2
           Version: Current CVS
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: general components
        AssignedTo: cocoon-dev@xml.apache.org
        ReportedBy: nbacon@pinnaclesoftware.com.au


Here's a patch for
cocoon-
2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/A
bstractEsqlConnection.java
to:
- fix an error with Sybase ASE (unlike Sybase ASA, ASE doesn't support "select 
top")
- enhance behavior with MS Sql Server (it supports "select top" like Sybase ASA)



--- AbstractEsqlConnection.java-1.2	2003-04-01 14:20:08.000000000 +1000
+++ AbstractEsqlConnection.java	2003-04-01 14:12:48.000000000 +1000
@@ -147,12 +147,26 @@
 
 
     /**
+     * Sybase has 2 RDBMS products. The Sybase JDBC driver uses a url starting 
with "jdbc:sybase:" for both.
+     * Here are the product names and versions returned from the Sybase JDBC 
driver:
+     * getMetaData().getDatabaseProductName()  getMetaData
().getDatabaseProductVersion()
+     * --------------------------------------  --------------------------------
---------
+     * Adaptive Server Anywhere                7.0.4.3373
+     * Sybase SQL Server                       Adaptive Server 
Enterprise/12.0.0.3/P/SWR 9777 ESD 4/NT (IX86)/OS 4.0/1699/32bit/OPT/Wed Sep 05 
21:14:50 2001
+     * The first supports "select TOP" as used by SybaseEsqlQuery, but the 
second does not.
+     */
+    private boolean isSybaseAdaptiveServerAnywhere() throws SQLException {
+	String databaseProductName = getConnection().getMetaData
().getDatabaseProductName().toLowerCase();
+	return databaseProductName.indexOf("anywhere") > -1;
+    }
+
+    /**
      * Factory method for creating an EsqlQuery object. If type is set to
      * "" or "auto" it will try to find type from the JDBC connection URL.
      * If this does not succeed the generic JDBC type will be assumed.
      * (This type does not work for some databases like mssql though)
      *
-     * @param type {sybase|postgresql|mysql|oracle|jdbc}
+     * @param type {sybase|sybase-ase|ms-
sqlserver|postgresql|mysql|oracle|jdbc}
      * @param queryString
      * @return implementation of the AbstractEsqlQuery
      * @throws SQLException
@@ -169,6 +183,15 @@
                 query = new MysqlEsqlQuery(getConnection(),queryString);
             }
             else if (url.startsWith("jdbc:sybase:")) {
+                if (isSybaseAdaptiveServerAnywhere()) {
+		    query = new SybaseEsqlQuery(getConnection(),queryString);
+		} else {
+		    query = new JdbcEsqlQuery(getConnection(),queryString);
+		}
+            }
+            else if (url.startsWith("jdbc:microsoft:sqlserver:")) {
+		// MS SQL Server also supports "select TOP" like Sybase ASA
+		// Maybe SybaseEsqlQuery should be renamed to something like 
SelectTopEsqlQuery?
                 query = new SybaseEsqlQuery(getConnection(),queryString);
             }
             else if (url.startsWith("jdbc:oracle:")) {
@@ -182,7 +205,7 @@
                 query = new JdbcEsqlQuery(getConnection(),queryString);
             }
         }
-        else if ("sybase".equalsIgnoreCase(type)) {
+        else if ("sybase".equalsIgnoreCase(type) || "ms-
sqlserver".equalsIgnoreCase(type)) {
             query = new SybaseEsqlQuery(getConnection(),queryString);
         }
         else if ("postgresql".equalsIgnoreCase(type)) {
@@ -200,7 +223,7 @@
         else if ("pervasive".equalsIgnoreCase(type)) {
             query = new PervasiveEsqlQuery(getConnection(),queryString);
         }
-        else if ("jdbc".equalsIgnoreCase(type)) {
+        else if ("jdbc".equalsIgnoreCase(type) || "sybase-ase".equalsIgnoreCase
(type)) {
             query = new JdbcEsqlQuery(getConnection(),queryString);
         }
         else {

Mime
View raw message