⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setup3.jsp

📁 java开发的一套非常好用的oa系统
💻 JSP
📖 第 1 页 / 共 2 页
字号:
            String propName = descriptor.getName();
            validFields[i] = isParameterValid(request, conProvider, descriptor);
            if (!validFields[i]) {
                errors = true;
            }
            else {
                // field specific validation
                if (propName.equals("driver")) {
                    // try to load the driver
                    String driver = ParamUtils.getParameter(request,"driver");
                    try {
                        Class.forName(driver);
                    }
                    catch (Exception e) {
                        validFields[i] = false;
                        errors = true;
                    }
                }
            }
        }
    }

    // Get all of the parameters
    String driver = ParamUtils.getParameter(request,"driver");
    String serverURL = ParamUtils.getParameter(request,"serverURL");
    String username = ParamUtils.getParameter(request,"username");
    String password = ParamUtils.getParameter(request,"password");
    double connectionTimeout = ParamUtils.getDoubleParameter(request,"connectionTimeout",0.0);
    int maxConnections = ParamUtils.getIntParameter(request,"maxConnections",-1);
    int minConnections = ParamUtils.getIntParameter(request,"minConnections",-1);

    // Test the connection to the database if there are no errors and all fields
    // have been validated
    boolean conErrors = false;
    String conErrorMessage = null;
    if (!errors && validate) {
        // set all values passed in
        PropertyDescriptor descriptor = null;
        Method writeMethod = null;
        Object[] args = null;

        // ints: maxConnections, minConnections
        descriptor = getPropertyDescriptor(propDescriptors,"minConnections");
        writeMethod = descriptor.getWriteMethod();
        args = new Integer[1];
        args[0] = new Integer(minConnections);
        writeMethod.invoke(conProvider, args);

        descriptor = getPropertyDescriptor(propDescriptors,"maxConnections");
        writeMethod = descriptor.getWriteMethod();
        args = new Integer[1];
        args[0] = new Integer(maxConnections);
        writeMethod.invoke(conProvider, args);

        // double: connectionTimeout
        descriptor = getPropertyDescriptor(propDescriptors,"connectionTimeout");
        writeMethod = descriptor.getWriteMethod();
        args = new Double[1];
        args[0] = new Double(connectionTimeout);
        writeMethod.invoke(conProvider, args);

        // Strings: driver, serverURL, username and password
        descriptor = getPropertyDescriptor(propDescriptors,"driver");
        writeMethod = descriptor.getWriteMethod();
        args = new String[1];
        args[0] = driver;
        writeMethod.invoke(conProvider, args);

        descriptor = getPropertyDescriptor(propDescriptors,"serverURL");
        writeMethod = descriptor.getWriteMethod();
        args = new String[1];
        args[0] = serverURL;
        writeMethod.invoke(conProvider, args);

        descriptor = getPropertyDescriptor(propDescriptors,"username");
        writeMethod = descriptor.getWriteMethod();
        args = new String[1];
        args[0] = username;
        writeMethod.invoke(conProvider, args);

        descriptor = getPropertyDescriptor(propDescriptors,"password");
        writeMethod = descriptor.getWriteMethod();
        args = new String[1];
        args[0] = password;
        writeMethod.invoke(conProvider, args);

        ConnectionManager.setConnectionProvider(conProvider);
        Connection con = null;
        try {
            con = ConnectionManager.getConnection();
            if (con == null) {
                conErrors = true;
                conErrorMessage = "A connection to the database could not be "
                    + "made. View the error message by opening the "
                    + "\"jiveHome\\logs\\DefaultConnectionProvider.log\" log "
                    + "file, then go back to fix the problem.";
            }
            else {
            	// See if the Jive db schema is installed.
            	try {
            		java.sql.Statement stmt = con.createStatement();
            		// Pick an arbitrary table to see if it's there.
            		stmt.executeQuery("SELECT * FROM jiveID");
            		stmt.close();
            	}
            	catch (SQLException sqle) {
            		sqle.printStackTrace();
            		conErrors = true;
            		conErrorMessage = "The Jive Forums database schema does not "
                        + "appear to be installed. Follow the installation guide to "
                        + "fix this error.";
            	}
            }
        }
        finally {
            try {
        	    con.close();
            } catch (Exception ignored) {}
        }
    }

    if (!errors && !conErrors && validate) {
        // set all the values
        response.sendRedirect("setup4.jsp");
        return;
    }
%>

<%@ include file="include/global.jsp" %>

<%@ include file="include/header.jsp" %>

<table cellpadding="6" cellspacing="0" border="0" width="100%">
<tr>
<td width="1%" valign="top">
<%  // set sidebar properties
    session.setAttribute("sidebar.2.active", new Boolean(true));
    if (!GREEN.equals(getSessionString(session,"sidebar.2.light"))) {
        session.setAttribute("sidebar.2.light", YELLOW);
    }
%>
<%@ include file="include/sidebar.jsp" %>
</td>
<td width="99%" valign="top">

    <b><%= bundle.getString("setup3.header") %></b>
    <hr size="0">

    <font size="-1">
    <%= bundle.getString("setup3.top_msg") %>
    </font>
    <p>

    <%  if (conErrors) { %>
        <font size="-1" color="#ff0000">
        <%= conErrorMessage %>
        <p>
        </font>
    <%  } %>

<form action="setup3.jsp" method="post">
<input type="hidden" name="validate" value="true">

<table cellpadding="4" cellspacing="0" border="0">
<%  int row = 0;
    for (int i=0; i<propertyNames.length; i++) {
        PropertyDescriptor descriptor = getPropertyDescriptor(propDescriptors, propertyNames[i]);
        String propName = descriptor.getName();
        String errorMessage = (String)dbFieldErrorMessages.get(propName);
        String bgcolor = (row++%2==0)?"#f2f8ff":"#ffffff";
%>
<tr bgcolor="<%= bgcolor %>">
    <td width="1%" nowrap>
        <font size="-1">
        <%= descriptor.getDisplayName() %>
        </font>
    </td>
    <td width="1%"><%= getHTML(request, conProvider,descriptor) %></td>
    <td width="98%">&nbsp;</td>
</tr>
<tr bgcolor="<%= bgcolor %>">
    <td colspan="3">
        <table cellpadding="0" cellspacing="0" width="100%" border="0">
        <td width="1%"><img src="images/blank.gif" width="25" height="1" border="0"></td>
        <td width="99%">
        <font size="-2">
<%      if (validate && !validFields[i]) { %>
        <font color="#cc3300"><%= errorMessage %></font>
        <br>
<%      } %>
        <%= descriptor.getShortDescription() %>
        </font>
        </td>
        </table>
    </td>
</tr>
<%  } %>
</table>

<p>

<hr size="0">
<div align="center">
<input type="submit" value="Test Connection...">
<br>
<font size="-2">(This may take up to a minute)</font>
</form>
</div>

</form>

<jsp:include page="include/footer.jsp" flush="true"/>

</td>
</tr>
</table>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -