Project

General

Profile

« Previous | Next » 

Revision 184

cleaned up code for getting options from the properties file, made the database connection inthe MetaCatUtil class use the properties file for the conneciton info

View differences:

MetaCatServlet.java
71 71
  private DBQuery		queryobj = null;
72 72
  private DBReader		docreader = null;
73 73
  private DBTransform		dbt = null;
74
  private String 		user = null;
75
  private String 		password = null;
76
  private String 		defaultDB = null;
77 74
  private String 		resultStyleURL = null;
78 75
  private String 		xmlcatalogfile = null;
79 76
  private String 		saxparser = null;
......
85 82
                                    	// in defaultdocpath dir
86 83
  private PropertyResourceBundle options = null;
87 84

  
85
  private MetaCatUtil util = null;
86

  
88 87
  /**
89 88
   * Initialize the servlet by creating appropriate database connections
90 89
   */
......
93 92
      super.init( config );
94 93
      this.config = config;
95 94
      this.context = config.getServletContext();
96
      System.out.println("Servlet Initialize");
95
      System.out.println("MetaCatServlet Initialize");
97 96

  
97
      util = new MetaCatUtil();
98

  
98 99
      // Get the configuration file information
99
      options = (PropertyResourceBundle)
100
          PropertyResourceBundle.getBundle("edu.ucsb.nceas.metacat.metacat");
101
      user = (String)options.handleGetObject("user");
102
      password = (String)options.handleGetObject("password");
103
      defaultDB = (String)options.handleGetObject("defaultDB");
104
      resultStyleURL = (String)options.handleGetObject("resultStyleURL");
105
      xmlcatalogfile = (String)options.handleGetObject("xmlcatalogfile");
106
      saxparser = (String)options.handleGetObject("saxparser");
107
      defaultdatapath = (String)options.handleGetObject("defaultdatapath");
108
      executescript = (String)options.handleGetObject("executescript");
100
      resultStyleURL = util.getOption("resultStyleURL");
101
      xmlcatalogfile = util.getOption("xmlcatalogfile");
102
      saxparser = util.getOption("saxparser");
103
      defaultdatapath = util.getOption("defaultdatapath");
104
      executescript = util.getOption("executescript");
109 105

  
110 106
      try {
111 107
        // Open a connection to the database
112
        conn = MetaCatUtil.openDBConnection(
113
                "oracle.jdbc.driver.OracleDriver",
114
                defaultDB, user, password);
108
        conn = util.openDBConnection();
115 109

  
116 110
        queryobj = new DBQuery(conn,saxparser);
117 111
        docreader = new DBReader(conn);
......
152 146
      System.err.println("Connection to database lost.  Reopening...");
153 147
      try {
154 148
        // Open a connection to the database
155
        conn = MetaCatUtil.openDBConnection(
156
                "oracle.jdbc.driver.OracleDriver",
157
                defaultDB, user, password);
149
        conn = util.openDBConnection();
158 150
  
159 151
        queryobj = new DBQuery(conn, saxparser);
160 152
        docreader = new DBReader(conn);

Also available in: Unified diff