1 10 11 package com.triactive.jdo.store; 12 13 import java.math.BigInteger ; 14 import java.sql.Connection ; 15 import java.sql.DatabaseMetaData ; 16 import java.sql.ResultSet ; 17 import java.sql.SQLException ; 18 import java.sql.Statement ; 19 import java.util.ArrayList ; 20 import javax.jdo.JDOFatalDataStoreException; 21 22 23 32 33 class MSSQLServerAdapter extends DatabaseAdapter 34 { 35 41 42 protected MSSQLServerAdapter(DatabaseMetaData metadata) 43 { 44 super(metadata); 45 } 46 47 public String getVendorID() 48 { 49 return "sqlserver"; 50 } 51 52 public String getSchemaName(Connection conn) throws SQLException 53 { 54 65 return null; 66 } 67 68 public boolean supportsBooleanComparison() 69 { 70 return false; 71 } 72 73 public boolean supportsDeferredConstraints() 74 { 75 return false; 76 } 77 78 public ColumnInfo newColumnInfo(ResultSet rs) 79 { 80 return new MSSQLServerColumnInfo(rs); 81 } 82 83 public TableExpression newTableExpression(QueryStatement qs, Table table, SQLIdentifier rangeVar) 84 { 85 return new TableExprAsJoins(qs, table, rangeVar); 86 } 87 88 public TypeInfo newTypeInfo(ResultSet rs) 89 { 90 TypeInfo ti = new TypeInfo(rs); 91 92 95 if (ti.typeName.toLowerCase().startsWith("tinyint")) 96 return null; 97 98 return ti; 99 } 100 public String getDropTableStatement(BaseTable table) 101 { 102 return "DROP TABLE " + table.getName(); 103 } 104 105 public NumericExpression lengthMethod(CharacterExpression str) 106 { 107 ArrayList args = new ArrayList (); 108 args.add(str); 109 110 return new NumericExpression("LEN", args); 111 } 112 113 public CharacterExpression substringMethod(CharacterExpression str, 114 NumericExpression begin) 115 { 116 ArrayList args = new ArrayList (); 117 args.add(str); 118 args.add(begin.add(new IntegerLiteral(str.getQueryStatement(), BigInteger.ONE))); 119 args.add(lengthMethod(str).sub(begin)); 120 121 return new CharacterExpression("SUBSTRING", args); 122 } 123 124 public CharacterExpression substringMethod(CharacterExpression str, 125 NumericExpression begin, 126 NumericExpression end) 127 { 128 ArrayList args = new ArrayList (); 129 args.add(str); 130 args.add(begin.add(new IntegerLiteral(str.getQueryStatement(), BigInteger.ONE))); 131 args.add(end.sub(begin)); 132 133 return new CharacterExpression("SUBSTRING", args); 134 } 135 } 136 | Popular Tags |