commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder MySqlBuilder.java
Date Fri, 09 Jul 2004 12:53:19 GMT
tomdz       2004/07/09 05:53:19

  Modified:    sql/src/java/org/apache/commons/sql/builder
                        MySqlBuilder.java
  Log:
  Fixed jdbc <-> database type mapping for MySql
  
  Revision  Changes    Path
  1.8       +18 -8     jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/MySqlBuilder.java
  
  Index: MySqlBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/MySqlBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MySqlBuilder.java	28 Feb 2004 03:35:47 -0000	1.7
  +++ MySqlBuilder.java	9 Jul 2004 12:53:19 -0000	1.8
  @@ -17,6 +17,7 @@
   package org.apache.commons.sql.builder;
   
   import java.io.IOException;
  +import java.util.HashMap;
   import java.util.List;
   
   import org.apache.commons.sql.model.Column;
  @@ -27,12 +28,24 @@
    * 
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @author John Marshall/Connectria
  + * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
    * @version $Revision$
    */
   public class MySqlBuilder extends SqlBuilder {
  -    
  +    private HashMap _specialTypes = new HashMap();
  +
       public MySqlBuilder() {
           setForeignKeysEmbedded(true);
  +        _specialTypes.put("binary",        "BLOB");
  +        _specialTypes.put("blob",          "LONGBLOB");
  +        _specialTypes.put("boolean",       "BIT");
  +        _specialTypes.put("clob",          "LONGTEXT");
  +        _specialTypes.put("float",         "DOUBLE");
  +        _specialTypes.put("longvarbinary", "MEDIUMBLOB");
  +        _specialTypes.put("longvarchar",   "MEDIUMTEXT");
  +        _specialTypes.put("real",          "FLOAT");
  +        _specialTypes.put("timestamp",     "DATETIME");
  +        _specialTypes.put("varbinary",     "BLOB");
       }
       
       public void dropTable(Table table) throws IOException { 
  @@ -54,12 +67,9 @@
       }
   
       protected String getNativeType(Column column){
  -        if ( "timestamp".equalsIgnoreCase( column.getType() ) ) {
  -            return "DATETIME";
  -        } else if ( "longvarchar".equalsIgnoreCase( column.getType() ) ) {
  -            return "TEXT";
  -        } else {
  -            return column.getType();
  -        }
  +        String type        = column.getType();
  +        String specialType = (String)_specialTypes.get(type.toLowerCase());
  +
  +        return (specialType == null ? type : specialType);
       }
   }
  
  
  

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


Mime
View raw message