Project

General

Profile

« Previous | Next » 

Revision 31

Added by Matt Jones over 24 years ago

documentation additions

View differences:

DBReader.java
15 15
import java.sql.*;
16 16
import java.util.Stack;
17 17

  
18
/** 
19
 * A Class that creates an XML text document
20
 * from a query to a relational DB containing a DOM representation
21
 */
18 22
public class DBReader {
19 23

  
20 24
  static  String 	defaultDB = "jdbc:oracle:thin:@localhost:1521:test";
21 25
  private Connection	conn = null;
22 26

  
27
  /**
28
   * main routine used for testing.
29
   *
30
   * Usage: java DBReader <nodeid> <user> <password> [dbstring]
31
   *
32
   * @param nodeid the id number of the root of the subtree to display
33
   * @param user the username to use for the database connection
34
   * @param password the password to use for the database connection
35
   * @param dbstring the connection info to use for the database connection
36
   */
23 37
  static public void main(String[] args) {
24 38
     
25 39
     if (args.length < 3)
......
44 58
          }
45 59

  
46 60
          DBReader rd = new DBReader(user, password, dbstring);
47
          String xml = rd.readDocument(nodeid);
61
          String xml = rd.readXMLDocument(nodeid);
48 62
          System.out.println(xml);
49 63

  
50 64
        } catch (Exception e) {
......
55 69
     }
56 70
  }
57 71
  
72
  /**
73
   * construct a DBReader instance.
74
   *
75
   * Generally, one calls readXMLDocument() after constructing the instance
76
   *
77
   * @param user the username to use for the database connection
78
   * @param password the password to use for the database connection
79
   * @param dbstring the connection info to use for the database connection
80
   */
58 81
  public DBReader( String user, String password, String dbstring) 
59 82
                  throws IOException, 
60 83
                         SQLException, 
......
67 90

  
68 91
  }
69 92
  
93
  /** open a connection to the database with the supplied information */
70 94
  private Connection openDBConnection(String dbDriver, String connection,
71 95
                String user, String password)
72 96
                throws SQLException, ClassNotFoundException {
......
78 102
     return conn;
79 103
  }
80 104

  
81
  public String readDocument(long nodeid) {
105
  /**
106
   * Create an XML document from the database starting with the element 
107
   * having element_id nodeid
108
   *
109
   * @param nodeid the node that will represent the root of the document
110
   */
111
  public String readXMLDocument(long nodeid) {
82 112
    StringBuffer doc = new StringBuffer();
83 113

  
84 114
    ReaderElement element = new ReaderElement(conn, nodeid);

Also available in: Unified diff