1 30 31 32 package org.hsqldb.util; 33 34 import java.sql.Types ; 35 36 38 43 class SqlServerTransferHelper extends TransferHelper { 44 45 private boolean firstTinyintRow; 46 private boolean firstSmallintRow; 47 48 SqlServerTransferHelper() { 49 super(); 50 } 51 52 SqlServerTransferHelper(TransferDb database, Traceable t, String q) { 53 super(database, t, q); 54 } 55 56 String formatTableName(String t) { 57 58 if (t == null) { 59 return t; 60 } 61 62 if (t.equals("")) { 63 return t; 64 } 65 66 if (t.indexOf(' ') != -1) { 67 return ("[" + t + "]"); 68 } else { 69 return (formatIdentifier(t)); 70 } 71 } 72 73 int convertFromType(int type) { 74 75 if (type == 11) { 77 tracer.trace("Converted DATETIME (type 11) to TIMESTAMP"); 78 79 type = Types.TIMESTAMP; 80 } else if (type == -9) { 81 tracer.trace("Converted NVARCHAR (type -9) to VARCHAR"); 82 83 type = Types.VARCHAR; 84 } else if (type == -8) { 85 tracer.trace("Converted NCHAR (type -8) to VARCHAR"); 86 87 type = Types.VARCHAR; 88 } else if (type == -10) { 89 tracer.trace("Converted NTEXT (type -10) to VARCHAR"); 90 91 type = Types.VARCHAR; 92 } else if (type == -1) { 93 tracer.trace("Converted LONGTEXT (type -1) to LONGVARCHAR"); 94 95 type = Types.LONGVARCHAR; 96 } 97 98 return (type); 99 } 100 101 void beginTransfer() { 102 firstSmallintRow = true; 103 firstTinyintRow = true; 104 } 105 106 Object convertColumnValue(Object value, int column, int type) { 107 108 if ((type == Types.SMALLINT) && (value instanceof Integer )) { 110 if (firstSmallintRow) { 111 firstSmallintRow = false; 112 113 tracer.trace("SMALLINT: Converted column " + column 114 + " Integer to Short"); 115 } 116 117 value = new Short ((short) ((Integer ) value).intValue()); 118 } else if ((type == Types.TINYINT) && (value instanceof Integer )) { 119 if (firstTinyintRow) { 120 firstTinyintRow = false; 121 122 tracer.trace("TINYINT: Converted column " + column 123 + " Integer to Byte"); 124 } 125 126 value = new Byte ((byte) ((Integer ) value).intValue()); 127 } 128 129 return (value); 130 } 131 } 132 | Popular Tags |