简单的学生信息管理系统
//连接数据库方法类
JDBCConnection.java
packagegj;
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.SQLException;
public class JDBCConnection {
String driverName = "com.mysql.jdbc.Driver"; //驱动程序名String userName = "root"; //数据库用户名
String userPwd = "text"; //密码
String dbName = "user"; //数据库名
String tableName = "user_list3"; //数据表名
String url ="";
public String getDriverName() {
returndriverName;
}
public void setDriverName(String driverName) {
this.driverName = driverName;
}
public String getUserName() {
returnuserName;
}
public void setUserName(String userName) {
https://www.360docs.net/doc/8c14694163.html,erName = userName;
}
public String getUserPwd() {
returnuserPwd;
}
public void setUserPwd(String userPwd) {
https://www.360docs.net/doc/8c14694163.html,erPwd = userPwd;
}
public String getDbName() {
returndbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
public String getTableName() {
returntableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getUrl() {
returnurl;
}
public void setUrl(String url) {
this.url = url;
}
//实现数据库连接的方法
public Connection getConnection() throws SQLException, ClassNotFoundException { //实现数据库连接的方法
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2 ="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=GB2312"; url =url1+url2+url3;
Class.forName(driverName);
returnDriverManager.getConnection(url);
}
}
//用户登录界面
Index.jsp
function validate()
{
var userName=document.forms["form1"].UserName.value; var password=document.forms["form1"].pd.value;
if(userName.length<=0)
{
alert("用户名不能为空!");
}
else if(password<=0)
{
alert("密码不能为空!");
}
else
{
document.forms["form1"].submit();
}
}
用户登录
<%=request.getAttribute("return")%>
<%
int count = 0;
if (application.getAttribute("count") == null) {
count += 1;
application.setAttribute("count", count);
} else {
count = Integer.parseInt(application.getAttribute("count") .toString());
count += 1;
application.setAttribute("count", count);
}
out.print("您是本系统的第"+count+"位访问者!");
%>
<%=new Date() %>