1 19 package org.apache.cayenne.access; 20 21 import java.sql.Connection ; 22 import java.sql.PreparedStatement ; 23 import java.sql.SQLException ; 24 import java.util.HashMap ; 25 import java.util.Map ; 26 27 import org.apache.cayenne.dba.AutoAdapter; 28 import org.apache.cayenne.dba.DbAdapter; 29 import org.apache.cayenne.dba.hsqldb.HSQLDBAdapter; 30 31 38 class DbGeneratorPostprocessor { 39 40 private static final Map postprocessors; 41 42 static { 43 postprocessors = new HashMap (); 44 postprocessors.put(HSQLDBAdapter.class.getName(), new HSQLDBPostprocessor()); 45 } 46 47 void execute(Connection connection) throws SQLException { 48 49 DbAdapter adapter = AutoAdapter.getDefaultFactory().createAdapter( 50 connection.getMetaData()); 51 if (adapter != null) { 52 Postprocessor postprocessor = (Postprocessor) postprocessors.get(adapter 53 .getClass() 54 .getName()); 55 if (postprocessor != null) { 56 postprocessor.execute(connection); 57 } 58 } 59 } 60 61 static abstract class Postprocessor { 62 63 abstract void execute(Connection c) throws SQLException ; 64 } 65 66 static class HSQLDBPostprocessor extends Postprocessor { 67 68 void execute(Connection c) throws SQLException { 69 PreparedStatement st = c.prepareStatement("CHECKPOINT"); 70 try { 71 st.execute(); 72 } 73 finally { 74 st.close(); 75 } 76 } 77 } 78 } 79 | Popular Tags |