1 19 20 package org.apache.cayenne.dba.sqlserver; 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 SQLServerSniffer implements DbAdapterFactory { 35 36 public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException { 37 String dbName = md.getDatabaseProductName(); 38 if (dbName == null || dbName.toUpperCase().indexOf("MICROSOFT SQL SERVER") < 0) { 39 return null; 40 } 41 42 SQLServerAdapter adapter = new SQLServerAdapter(); 43 44 46 boolean generatedKeys = false; 47 try { 48 generatedKeys = md.supportsGetGeneratedKeys(); 49 } 50 catch (Throwable th) { 51 } 55 56 adapter.setSupportsGeneratedKeys(generatedKeys); 57 return adapter; 58 } 59 } 60 | Popular Tags |