1 19 20 package org.apache.cayenne.dba.sybase; 21 22 import java.sql.PreparedStatement ; 23 import java.sql.SQLException ; 24 import java.sql.Types ; 25 26 import org.apache.cayenne.access.types.ByteArrayType; 27 import org.apache.cayenne.access.types.ByteType; 28 import org.apache.cayenne.access.types.CharType; 29 import org.apache.cayenne.access.types.ExtendedTypeMap; 30 import org.apache.cayenne.access.types.ShortType; 31 import org.apache.cayenne.dba.JdbcAdapter; 32 import org.apache.cayenne.dba.PkGenerator; 33 34 39 public class SybaseAdapter extends JdbcAdapter { 40 41 46 public String getBatchTerminator() { 47 return "go"; 48 } 49 50 54 protected void configureExtendedTypes(ExtendedTypeMap map) { 55 super.configureExtendedTypes(map); 56 57 map.registerType(new CharType(true, false)); 59 60 map.registerType(new ByteArrayType(true, false)); 62 63 map.registerType(new ShortType(true)); 65 map.registerType(new ByteType(true)); 66 } 67 68 73 protected PkGenerator createPkGenerator() { 74 return new SybasePkGenerator(); 75 } 76 77 public void bindParameter( 78 PreparedStatement statement, 79 Object object, 80 int pos, 81 int sqlType, 82 int precision) 83 throws SQLException , Exception { 84 85 if (object == null) { 87 if (sqlType == Types.CLOB) { 88 sqlType = Types.VARCHAR; 89 } 90 else if (sqlType == Types.BLOB) { 91 sqlType = Types.VARBINARY; 92 } 93 } 94 95 super.bindParameter(statement, object, pos, sqlType, precision); 96 } 97 } 98 | Popular Tags |