1 21 22 package org.apache.derby.impl.tools.dblook; 23 24 import java.sql.Connection ; 25 import java.sql.Statement ; 26 import java.sql.ResultSet ; 27 import java.sql.SQLException ; 28 29 import java.util.HashMap ; 30 31 import org.apache.derby.tools.dblook; 32 33 public class DB_View { 34 35 42 43 public static void doViews(Connection conn) 44 throws SQLException { 45 46 Statement stmt = conn.createStatement(); 47 ResultSet rs = stmt.executeQuery("SELECT V.VIEWDEFINITION, " + 48 "T.TABLENAME, T.SCHEMAID, V.COMPILATIONSCHEMAID FROM SYS.SYSVIEWS V, " + 49 "SYS.SYSTABLES T WHERE T.TABLEID = V.TABLEID"); 50 51 boolean firstTime = true; 52 while (rs.next()) { 53 54 String viewSchema = dblook.lookupSchemaId(rs.getString(3)); 55 if (dblook.isIgnorableSchema(viewSchema)) 56 continue; 57 58 if (!dblook.stringContainsTargetTable(rs.getString(1))) 59 continue; 60 61 if (firstTime) { 62 Logs.reportString("----------------------------------------------"); 63 Logs.reportMessage("DBLOOK_ViewsHeader"); 64 Logs.reportString("----------------------------------------------\n"); 65 } 66 67 Logs.writeToNewDDL("SET SCHEMA "); 73 Logs.writeToNewDDL(dblook.lookupSchemaId(rs.getString(4))); 74 Logs.writeStmtEndToNewDDL(); 75 76 Logs.writeToNewDDL(dblook.removeNewlines(rs.getString(1))); 78 Logs.writeStmtEndToNewDDL(); 79 Logs.writeNewlineToNewDDL(); 80 firstTime = false; 81 82 } 83 84 if (!firstTime) { 86 Logs.reportMessage("DBLOOK_DefaultSchema"); 87 Logs.writeToNewDDL("SET SCHEMA \"APP\""); 88 Logs.writeStmtEndToNewDDL(); 89 Logs.writeNewlineToNewDDL(); 90 } 91 92 rs.close(); 93 stmt.close(); 94 return; 95 96 } 97 98 } 99 | Popular Tags |