1 19 20 package org.apache.cayenne.dba.hsqldb; 21 22 import java.sql.DatabaseMetaData ; 23 import java.sql.SQLException ; 24 25 import org.apache.cayenne.dba.DbAdapter; 26 import org.apache.cayenne.dba.DbAdapterFactory; 27 28 34 public class HSQLDBSniffer implements DbAdapterFactory { 35 36 public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException { 37 String dbName = md.getDatabaseProductName(); 38 if (dbName == null || dbName.toUpperCase().indexOf("HSQL") < 0) { 39 return null; 40 } 41 42 boolean supportsSchema = false; 43 if (md.getDriverMajorVersion() < 1) { 44 supportsSchema = true; 45 } 46 else if (md.getDriverMajorVersion() == 1) { 47 if (md.getDriverMinorVersion() <= 8) { 48 supportsSchema = true; 49 } 50 else { 51 supportsSchema = false; 52 } 53 } 54 else { 55 supportsSchema = false; 56 } 57 58 return supportsSchema 59 ? new HSQLDBAdapter() 60 : new HSQLDBNoSchemaAdapter(); 61 } 62 } 63 | Popular Tags |