KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > db > explorer > infos > ProcedureListNodeInfo


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.db.explorer.infos;
21
22 import java.sql.ResultSet JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Vector JavaDoc;
25 import org.netbeans.api.db.explorer.DatabaseException;
26 import org.netbeans.lib.ddl.impl.DriverSpecification;
27 import org.netbeans.modules.db.explorer.nodes.DatabaseNode;
28
29 public class ProcedureListNodeInfo extends DatabaseNodeInfo {
30     static final long serialVersionUID =-7911927402768472443L;
31
32     public void initChildren(Vector JavaDoc children) throws DatabaseException {
33         try {
34             DriverSpecification drvSpec = getDriverSpecification();
35             drvSpec.getProcedures("%");
36             ResultSet JavaDoc rs = drvSpec.getResultSet();
37             if (rs != null) {
38                 HashMap JavaDoc rset = new HashMap JavaDoc();
39                 DatabaseNodeInfo info;
40                 while (rs.next()) {
41                     rset = drvSpec.getRow();
42                     
43                     //workaround for issue #21409 (http://db.netbeans.org/issues/show_bug.cgi?id=21409)
44
if (drvSpec.getDBName().indexOf("Oracle") != -1) {
45                         String JavaDoc pac = (String JavaDoc) rset.get(new Integer JavaDoc(1));
46                         if (pac != null)
47                             rset.put(new Integer JavaDoc(3), pac + "." + rset.get(new Integer JavaDoc(3)));
48                     }
49
50                     info = DatabaseNodeInfo.createNodeInfo(this, DatabaseNode.PROCEDURE, rset);
51                     if (info != null) {
52                         info.put(DatabaseNode.PROCEDURE, info.getName());
53                         children.add(info);
54                     } else
55                         throw new Exception JavaDoc(bundle().getString("EXC_UnableToCreateProcedureNodeInfo")); //NOI18N
56
rset.clear();
57                 }
58                 rs.close();
59             }
60         } catch (Exception JavaDoc e) {
61             DatabaseException dbe = new DatabaseException(e.getMessage());
62             dbe.initCause(e);
63             throw dbe;
64         }
65     }
66
67 }
68
Popular Tags