setup2.jsp
资源名称:NetOffice.rar [点击查看]
上传用户:guhaomin
上传日期:2007-06-10
资源大小:23203k
文件大小:4k
源码类别:
电子政务应用
开发平台:
Java
- <%
- /**
- * Jive Setup Tool
- * November 28, 2000
- */
- %>
- <%@ page import="java.io.*,
- java.util.*,
- java.sql.*,
- com.coolservlets.forum.*,
- com.coolservlets.forum.util.*,
- com.coolservlets.forum.database.*"%>
- <%!
- private String[] getPropertyNames( DbConnectionProvider conProvider ) {
- Enumeration enum = conProvider.propertyNames();
- Vector v = new Vector();
- while( enum.hasMoreElements() ) {
- v.addElement( enum.nextElement() );
- }
- String[] propNames = new String[ v.size() ];
- v.copyInto(propNames);
- return propNames;
- }
- %>
- <%
- DbConnectionProvider conProvider = new DbConnectionDefaultPool();
- boolean error = false;
- String errorMessage = null;
- String[] propNames = getPropertyNames(conProvider);
- String[] paramPropVals = new String[propNames.length];
- //Make sure the install has not already been completed.
- String setup = PropertyManager.getProperty("setup");
- if( setup != null && setup.equals("true") ) {
- error = true;
- errorMessage = "BBS设置已经完成,如果您想重新设置,请删除jive.properties配置文件中'setup=true'字段,然后再试。";
- }
- // get parameters:
- boolean setProps = ParamUtils.getBooleanParameter(request,"setProps");
- if( !error && setProps ) {
- for( int i=0; i<propNames.length; i++ ) {
- paramPropVals[i] = ParamUtils.getParameter(request,propNames[i]);
- if( paramPropVals[i] == null ) {
- paramPropVals[i] = "";
- }
- }
- for( int i=0; i < paramPropVals.length; i++ ) {
- conProvider.setProperty(propNames[i], paramPropVals[i]);
- }
- //Now test the connection. In this version of the install tool we test the driver name to make sure
- //it can be loaded. In the future, we might not want to do this in the generic case because the setup
- //tool needs to handle any possible connection provider setup. Perhaps we'll have specialized pages
- //for the common connection providers.
- Connection con = null;
- String driver = null;
- try {
- driver = ParamUtils.getParameter(request, "driver");
- Class.forName(driver);
- }
- catch (ClassNotFoundException cnfe) {
- error = true;
- errorMessage = "无法装载JDBC驱动:" + driver + "请确认驱动文件存在于系统的classpath中。";
- }
- if (!error) {
- //Set the connection provider.
- DbConnectionManager.setDbConnectionProvider(conProvider);
- try {
- con = DbConnectionManager.getConnection();
- if (con == null) {
- error = true;
- errorMessage = "无法建立到数据库的链接,请回退确认所有的字段都正确的填写了。";
- }
- }
- catch (Exception e) {
- error = true;
- }
- finally {
- try {
- con.close();
- } catch( Exception ignored ) {}
- }
- }
- if (!error) {
- // redirect
- response.sendRedirect("setup3.jsp");
- return;
- }
- }
- %>
- <html>
- <head>
- <title>BBS设置-第二步</title>
- <link rel="stylesheet" href="style/global.css">
- </head>
- <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
- <img src="images/setup.gif" width="210" height="38" alt="BBS设置" border="0">
- <hr size="0"><p>
- <%
- if (!error) {
- %>
- <b>设置数据库连接</b>
- <ul>
- <font size="2">
- 为了BBS系统的正确运作,必须设置数据库信息。请正确填写如下数据库参数字段。
- 注意:此操作之前,您必须已经在数据库中建立好所有BBS系统所需要的表。
- <p>
- <form action="setup2.jsp" method="post">
- <input type="hidden" name="setProps" value="true">
- <table cellpadding="3" cellspacing="0" border="0">
- <% for( int i=0; i<propNames.length; i++ ) {
- String prop = conProvider.getProperty(propNames[i]);
- String val = paramPropVals[i];
- %>
- <tr>
- <% if( setProps ) { %>
- <td><font size="-1" color="#ff0000"><%= propNames[i] %></font></td>
- <% }
- else { %>
- <td><font size="-1"><%= propNames[i] %></font></td>
- <% } %>
- <%
- if( val == null ) {
- val = PropertyManager.getProperty("DbConnectionDefaultPool."+propNames[i]);
- if( val == null ) {
- val = "";
- }
- }
- %>
- <td><input type="text" size="30" name="<%= propNames[i] %>" value="<%= val %>"></td>
- <td><font size="-1"><i><%= conProvider.getPropertyDescription(propNames[i]) %></i></font></td>
- </tr>
- <% } %>
- </table>
- </ul>
- <center>
- <input type="submit" value="建立连接..">
- </center>
- </form>
- <%
- } //end no error
- else {
- %>
- <font color="Red">错误!</font>
- <p><font size=2>
- <%= errorMessage %>
- </font>
- <%
- } //end error
- %>
- <p>
- <hr size="0">
- <center><font size="-1"><i>www.visionnex.com</i></font></center>
- </font>
- </body>
- </html>