数据库连接-sqlite
private static Connection conn = null;
private static final String DRIVER = "org.sqlite.JDBC";
private static final String URL = "jdbc:sqlite:";
private static final String FILENAME = "d:/graduation_examination.db3";
public static Connection getConnection()
{
try
{
Class.forName(DRIVER).newInstance();
conn = DriverManager.getConnection(URL + FILENAME);
if (conn != null)
{
System.out.println("-----连接成功-----");
}
}
catch (Exception e)
{
e.printStackTrace();
}
return conn;
}
public static void closeConn(Connection connection)
{
if (connection != null)
{
try
{
connection.close();
connection = null;
}
catch (sqlException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void closePstmt(PreparedStatement pstmt)
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void closeRs(ResultSet rs)
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void closeStmt(Statement stmt)
{
if (stmt != null)
{
try
{
stmt.close();
stmt = null;
}
catch (sqlException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
登录界面布局代码
class="tableBorder">
background="/GraduationServer/images/login/login_bg3.gif"
class="whitenormal">
考试管理系统登录
background="/GraduationServer/images/login/login_bg1.gif"
align="center">
background="/GraduationServer/images/login/login_bg3.gif">
用户名:
background="/GraduationServer/images/login/login_bg3.gif">
background="/GraduationServer/images/login/login_bg3.gif">
密码:
background="/GraduationServer/images/login/login_bg3.gif">
align="right">
align="left">
登录验证代码实现
request.setCharacterEncoding("UTF-8");
String strNextToPage = "main.jsp";
String username = new String(request.getParameter("username")
.trim().getBytes("ISO-8859-1"),"UTF-8");
String password = new String(request.getParameter("password")
.trim().getBytes("ISO-8859-1"),"UTF-8");
String strMsgInfo = "";
if (username.equals(""))
{
strMsgInfo = "请输入用户名!";
out.println("
+ "')");
out
.println("");
return;
}
else if (password.equals(""))
{
strMsgInfo = "请输入密码!";
out.println("
+ "')");
out
.println("");
return;
}
TeacherLoginBiz teacherLoginBiz = new TeacherLoginBizImpl();
List teacherInfos = teacherLoginBiz.loginTeacheBiz(
username,password);
if (teacherInfos.size() == 1)
{
Iterator iterator = teacherInfos.iterator();
while (iterator.hasNext())
{
TeacherInfo teacherInfo = iterator.next();
System.out.println("-----id----"
+ teacherInfo.getTeacher_id() + ";----name----"
+ teacherInfo.getTeacher_name()
+ ";-------pwd------"
+ teacherInfo.getTeacher_pwd());
session.setAttribute("username",teacherInfo
.getTeacher_name());
session.setAttribute("password",teacherInfo
.getTeacher_pwd());
}
}
else
{
strMsgInfo = "登录失败,用户名或密码错误!";
}
if (!strMsgInfo.equals(""))
{
out.println("
+ "')");
out
.println("");
return;
}
out.println("
+ "';");
%>
总结
以上是编程之家为你收集整理的毕业设计-服务端全部内容,希望文章能够帮你解决毕业设计-服务端所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
小编个人微信号 jb51ccc
喜欢与人分享编程技术与工作经验,欢迎加入编程之家官方交流群!