📄 setup2.jsp
字号:
<%@ page session="true" contentType="text/html; charset=GB2312" %>
<%
/**
* Title: 校园.NET
* Description: 中国第五代(城域网-校园网)项目
* Copyright: Copyright (c) 2001
* Company: 赛灵通
* @author 宋新华
* @version 1.0
*/
%>
<%@ page import="java.io.*,
java.util.*,
java.sql.*,
net.xerllent.campus.*,
net.xerllent.campus.util.*,
net.xerllent.campus.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 = "系统数据库链接已经完成,如果还需要使用此工具建立新的数据库连接,请删除 xerllent.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 = "Could not load JDBC driver: " + driver + ". Be sure that the driver is in the " +
"classpath of your application server and then press the back button to try again.";
}
if (!error) {
//Set the connection provider.
DbConnectionManager.setDbConnectionProvider(conProvider);
try {
con = DbConnectionManager.getConnection();
if (con == null) {
error = true;
errorMessage = "A connection to the database could not be made. Press the back button to " +
"ensure that all fields were filled in properly.";
}
}
catch (Exception e) {
error = true;
}
finally {
try {
con.close();
} catch( Exception ignored ) {}
}
}
if (!error) {
// redirect
response.sendRedirect("setup3.jsp");
return;
}
}
%>
<html>
<head>
<title>Xerllent Setup - Step 2</title>
<link rel="stylesheet" href="style/global.css">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<font size="5">Xerllent产品安装</font>
<hr size="0">
<p>
<%
if (!error) {
%>
<form action="setup2.jsp" method="post"> <b>设置数据库链接</b>
<ul>
系统需要连接到数据库才能正常运行,填写下面连接到您的数据库的相关参数,注意:您必须完成了数据库参数文件的导入之后才能执行这步操作。
<p>
<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.xerllent.cn</i></font>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -