1 19 20 package org.netbeans.modules.db.explorer.infos; 21 22 import java.io.IOException ; 23 import java.sql.ResultSet ; 24 import java.util.Vector ; 25 import org.netbeans.api.db.explorer.DatabaseException; 26 import org.netbeans.lib.ddl.impl.AbstractCommand; 27 import org.netbeans.lib.ddl.impl.DriverSpecification; 28 import org.netbeans.lib.ddl.impl.Specification; 29 import org.netbeans.modules.db.explorer.nodes.DatabaseNode; 30 31 public class ViewNodeInfo extends DatabaseNodeInfo { 32 static final long serialVersionUID =8370676447530973161L; 33 34 public void initChildren(Vector children) throws DatabaseException { 35 try { 36 String view = (String )get(DatabaseNode.VIEW); 37 38 DriverSpecification drvSpec = getDriverSpecification(); 40 drvSpec.getColumns(view, "%"); 41 42 ResultSet rs = drvSpec.getResultSet(); 43 if (rs != null) { 44 DatabaseNodeInfo nfo; 45 while (rs.next()) { 46 nfo = DatabaseNodeInfo.createNodeInfo(this, DatabaseNode.VIEWCOLUMN, drvSpec.getRow()); 47 if (nfo != null) 48 children.add(nfo); 49 } 50 rs.close(); 51 } 52 } catch (Exception e) { 53 throw new DatabaseException(e.getMessage()); 54 } 55 } 56 57 public void setProperty(String key, Object obj) { 58 try { 59 if (key.equals("remarks")) setRemarks((String )obj); put(key, obj); 61 } catch (Exception ex) { 62 ex.printStackTrace(); 63 } 64 } 65 66 public void setRemarks(String rem) throws DatabaseException { 67 String viewname = (String )get(DatabaseNode.VIEW); 68 Specification spec = (Specification)getSpecification(); 69 try { 70 AbstractCommand cmd = spec.createCommandCommentView(viewname, rem); 71 cmd.setObjectOwner((String )get(DatabaseNodeInfo.SCHEMA)); 72 cmd.execute(); 73 } catch (Exception e) { 74 throw new DatabaseException(e.getMessage()); 75 } 76 } 77 78 public void delete() throws IOException { 79 try { 80 String code = getCode(); 81 String table = (String )get(DatabaseNode.TABLE); 82 Specification spec = (Specification)getSpecification(); 83 AbstractCommand cmd = spec.createCommandDropView(getName()); 84 cmd.setObjectOwner((String )get(DatabaseNodeInfo.SCHEMA)); 85 cmd.execute(); 86 } catch (Exception e) { 87 throw new IOException (e.getMessage()); 88 } 89 } 90 } 91 | Popular Tags |