Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/projectapollo/mysqladmin/MARootPageBroker.java


1   package org.projectapollo.mysqladmin;
2   
3   import apollo.*;
4   import apollo.Template.*;
5   import apollo.Session.*;
6   
7   import org.projectapollo.mysqladmin.MAMainMenu.*;
8   import apollo.Statistics.*;
9   
10  import java.io.*;
11  import java.sql.*;
12  
13  import java.util.*;
14  /** The Root Page Broker for the MysqlAdmin web application
15  */
16  
17  public class MARootPageBroker extends PageBroker {
18    public MARootPageBroker(ManagerTracker MT, String fquid, PageBroker PB) throws TemplatePageException {
19      super(MT,fquid,PB);
20      this.registerPageHandler("MAMainMenu",new MAMainMenuBroker(MT,"MAMainMenu", this));
21      //this.registerPageHandler("Statistics", new StatisticsHandler(MT,"Statistics",this));
22      MT.getPM().registerTemplatePage("", new TemplatePage(MT, this, "MA-Login.html"));
23    }
24    public HTTPResponse render(TransactionTracker TT, HTTPRequest req, WebSession thisSession) throws ApolloException {
25      if (req.getParameter("UserID") == null || req.getParameter("Database") == null | req.getParameter("Database").equals("")) {
26        Hashtable RT = new Hashtable();
27        RT.put("ServletPath",req.getServletPath());
28        return MT.getPM().getPage("").render(RT,null);
29      } else {
30        //Ok, now try to establish a database connection
31        try {
32          SerializableJDBCConnection sc = new SerializableJDBCConnection("org.gjt.mm.mysql.Driver","jdbc:mysql://"+req.getValue("Hostname")+":"+req.getValue("Port")+"/"+req.getValue("Database")+"?user="+req.getValue("UserID")+"&password="+req.getValue("Password"));
33   
34          //        Class.forName("org.gjt.mm.mysql.Driver").newInstance(); 
35          //    Connection c = DriverManager.getConnection("jdbc:mysql://"+req.getValue("Hostname")+":"+req.getValue("Port")+"/"+req.getValue("Database")+"?user="+req.getValue("Username")+"&password="+req.getValue("Password"));
36          //        SerializableJDBCConnection sc = new SerializableJDBCConnection(c);
37          thisSession = MT.getSM().newSession(null);
38          thisSession.setValue("DBConnection", sc);
39          thisSession.setValue("DatabaseName", req.getValue("Database"));
40          thisSession.setValue("Hostname", req.getValue("Hostname"));
41          thisSession.setValue("ServletPath", req.getServletPath());
42          thisSession.setServletPath(req.getServletPath());
43        } catch (Exception e) {
44          Hashtable hashReplacement = new Hashtable();
45             hashReplacement.put("Error",e.getMessage());
46          hashReplacement.put("ServletPath", req.getServletPath());
47           return MT.getPM().getPage("").render(hashReplacement,null);
48        }
49        return MT.getPM().handleRequest(TT, "MAMainMenu",req,thisSession);
50      }
51    }
52  }