主頁 > 知識庫 > JSP學生信息管理系統(tǒng)設計

JSP學生信息管理系統(tǒng)設計

熱門標簽:自繪地圖標注數(shù)據(jù) 潤滑油銷售電銷機器人 電銷機器人免培訓 外呼系統(tǒng)使用方法 南通通訊外呼系統(tǒng)產(chǎn)品介紹 如何看懂地圖標注點 給地圖標注得傭金 海外圖書館地圖標注點 電話機器人需要使用網(wǎng)絡嗎

本文實例為大家分享了JSP學生信息管理系統(tǒng)源碼,供大家參考,具體內(nèi)容如下

新建學生信息數(shù)據(jù)庫

1.添加記錄模塊

%@ page contentType="text/html" pageEncoding="UTF-8"%>

html>
 head> 
 title>添加新學生/title> 
 /head>

 body>
 form action="stuinsert2.jsp" method="post">
 table border="0" width="238" heigth="252">
 tr>td>學號:/td>td>input type="text" name="id">/td>/tr>
 tr>td>姓名/td>td>input type="text" name="name">/td>/tr>
 tr>td>性別/td>td>input type="text" name="sex">/td>/tr>
 tr>td>年齡/td>td>input type="text" name="age">/td>/tr>
 tr>td>專業(yè)/td>td>input type="text" name="sdept">/td>/tr>
 tr align="center">
 td colspan="2">
 input type="submit" value="提交">nbsp;nbsp;nbsp;
 input type="reset" value="取消">
 /td>
 /tr>
 /table>
 /form>
 /body>
/html>

%@ page language="java" import="java.sql.*" pageEncoding="UTF-8"%>
html>
 head>
 title>添加學生處理程序/title>
 /head>
 body>
 % Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
    String url="jdbc:sqlserver://localhost:1433; DatabaseName=p"; 
    String user="sa";
    String password="123456"; 
  Connection conn=DriverManager.getConnection(url,user,password);
  request.setCharacterEncoding("UTF-8");
  String id=request.getParameter("id");
  String name=request.getParameter("name");
  String sex=request.getParameter("sex");
  int age=Integer.parseInt(request.getParameter("age"));
  String sdept=request.getParameter("sdept");
  String sql=String.format("select * from student where Sno=%s",id);
  Statement stmt=conn.createStatement();
  PreparedStatement pstmt;
  ResultSet rs=stmt.executeQuery(sql);
  if(!(rs.next())){
  pstmt=conn.prepareStatement("insert into Student values(?,?,?,?,?)");
  pstmt.setString(1,id);
  pstmt.setString(2,name);
  pstmt.setString(3,sex);
  pstmt.setInt(4,age);
  pstmt.setString(5,sdept);
  pstmt.executeUpdate();
  out.print("添加成功");  
  %>
  a href="stuinsert.jsp" rel="external nofollow" rel="external nofollow" >返回菜單/a>br>
  a href="main.jsp" rel="external nofollow" >/a>
  %}else{
  out.println("該學號已存在");%>
  a href="stuinsert.jsp" rel="external nofollow" rel="external nofollow" >重新添加/a>
  %}%>
 /body>
/html>

2.查詢(all)模塊

%@ page language="java" import="java.sql.*" pageEncoding="UTF-8"%>
%@ page import="javax.sql.*" %>
%@ page import="javax.naming.*" %>
html>
 head>
 title>信息查看頁面/title>
 /head> 
 body>
 center>
 % DataSource ds=null;
  InitialContext ctx=new InitialContext();
  ds=(DataSource)ctx.lookup("java:comp/env/jdbc/sqlserver");
  Connection conn=ds.getConnection();
  PreparedStatement pstmt=conn.prepareStatement("select * from Student");
  ResultSet rs=pstmt.executeQuery();
 %>   
 table border="2" bgcolor="ccceee" width="650">
 tr bgcolor="CCCCCC" align="center">
  td>記錄條數(shù)/td>td>學號/td>td>姓名/td>
  td>性別/td>td>年齡/td>td>專業(yè)/td>
 /tr>
 %
  while(rs.next()){
 %> 
 tr align="center">
 td>%=rs.getRow()%>/td>
 td>%=rs.getString(1)%>/td>
 td>%=rs.getString(2)%>/td>
 td>%=rs.getString(3)%>/td>
 td>%=rs.getString(4)%>/td>
 td>%=rs.getString(5)%>/td>
 /tr>
 %}%>
 /center>
 %if(rs!=null){rs.close();}
  if(pstmt!=null){pstmt.close();}
  if(conn!=null){conn.close();}
  %>
 /table> 
 /body>
/html>

條件查詢模塊

%@ page language="java" pageEncoding="UTF-8"%>
html>
 head>
 title>My JSP 'stufind2.jsp' starting page/title>
 /head>
 body>
 請選擇查詢條件hr width="100%" size="3">
 form action="stufind3.jsp" method="post">
 性別input type="radio" value="男" name="sex" checked="checked">男
 input type="radio" value="女" name="sex">女
 年齡范圍:p>nbsp;nbsp;
 最?。篿nput type="text" name="a1">br>br>nbsp;
 最大:input type="text" name="a2">p>
 input type="submit" value="提交">
 input type="reset" value="取消">
 /form>
 /body>
/html>
%@ page contentType="text/html" import="java.sql.*" pageEncoding="UTF-8"%>
html>
 head>
 title>條件查詢處理頁面/title>
 /head>
 body>
 center>
 %Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
 String user="sa";
 String password="123456";
 String url="jdbc:sqlserver://localhost:1433;DatabaseName=p";
 Connection conn=DriverManager.getConnection(url,user,password);
 request.setCharacterEncoding("UTF-8");
 String sex=request.getParameter("sex");
 int age1=Integer.parseInt(request.getParameter("a1"));
 int age2=Integer.parseInt(request.getParameter("a2"));
 String sql="select * from Student where Ssex=? and Sage>=? and Sage=?";
 PreparedStatement pstmt=conn.prepareStatement(sql);
 pstmt.setString(1,sex);
 pstmt.setInt(2,age1);
 pstmt.setInt(3,age2);
 ResultSet rs=pstmt.executeQuery();
 %>
 table border="2" bgcolor="ccceee" width="650">
 tr bgcolcor="CCCCCC" align="center">
 td>記錄條數(shù)/td>td>學號/td>td>姓名/td>
 td>性別/td>td>年齡/td>td>專業(yè)/td>
 /tr>
 %while(rs.next()){ %>
 tr align="center">
 td>%=rs.getRow()%>/td>
 td>%=rs.getString(1)%>/td>
 td>%=rs.getString(2)%>/td>
 td>%=rs.getString(3)%>/td>
 td>%=rs.getString(4)%>/td>
 td>%=rs.getString(5)%>/td>
 /tr>
 %}%>
 /table>
 %if(rs!=null){rs.close();}
  if(pstmt!=null){pstmt.close();}
  if(conn!=null){conn.close();}
 %>
 /center>
 /body>
/html>

3.修改模塊

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
html>
 head> 
 title>修改提交頁面/title>
 /head>
 body>
 center>
  請選擇修改記錄所滿足的條件
 form action="stuupdate2.jsp" method="post">
  姓名: input type="text" name="name">br>br>
  性別: 男input type="radio" value="男" name="sex">
      女input type="radio" value="女" name="sex">br>br>
  input type="submit" value="提交">nbsp;nbsp;nbsp;
  input type="reset" value="取消">
 /form>
 /center>
 /body>
/html>
%@ page contentType="text/html" import="java.sql.*" pageEncoding="UTF-8"%>
html>
 head> 
 title>修改編輯頁面/title>
 /head>
 body>
 % Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  String user="sa";
  String password="123456";
  String url="jdbc:sqlserver://localhost:1433;DatabaseName=p";
  Connection conn=DriverManager.getConnection(url,user,password);
  request.setCharacterEncoding("UTF-8");
  String name=request.getParameter("name");
  String sex=request.getParameter("sex");
  session.setAttribute("sex",sex);
  session.setAttribute("name",name);
  String sql="select * from Student where Ssex=? and Sname=?";
  PreparedStatement pstmt=conn.prepareStatement(sql);
  pstmt.setString(1,sex);
  pstmt.setString(2,name);
  ResultSet rs=pstmt.executeQuery();
  if(rs.next()){
  String id=rs.getString("Sno");
  String name2=rs.getString("Sname");
  String sex2=rs.getString("Ssex");
  int age=rs.getInt("Sage");
  String sdept=rs.getString("Sdept");
  if(pstmt!=null){pstmt.close();}
  if(rs!=null){rs.close();}
  if(conn!=null){conn.close();}
  %>
  form action="stuupdate3.jsp" method="post">
  table border="0" width="238" height="252">
  tr>td>學號:/td>td>input type="text" name="id" value=%=id%>>/td>/tr>
  tr>td>姓名:/td>td>input type="text" name="name2" value=%=name2%>>/td>/tr>
  tr>td>性別:/td>td>input type="text" name="sex2" value=%=sex2%>>/td>/tr>
  tr>td>年齡:/td>td>input type="text" name="age" value=%=age%>>/td>/tr>
  tr>td>專業(yè):/td>td>input type="text" name="sdept" value=%=sdept%>>/td>/tr>
  tr align="center">
  td colspan="2">
  input type="submit" value="提交">nbsp;nbsp;nbsp;
  input type="reset" value="取消">
  /td>
  /tr>
  /table>
  /form>
  %}
  else{%>
      沒有找到合適條件的記錄??!%
   if(rs!=null){rs.close();}
   if(pstmt!=null){pstmt.close();}
   if(conn!=null){conn.close();}
 }%>
 /body>
/html>
%@ page language="java" import="java.sql.*" pageEncoding="UTF-8"%>
html>
 head> 
 title>修改后重寫頁面/title> 
 /head>
 body>
 % Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
  String url="jdbc:sqlserver://localhost:1433; DatabaseName=p"; 
  String user="sa";
  String password="123456"; 
  Connection conn=DriverManager.getConnection(url,user,password);
  String sql="update Student set Sno=?,Sname=?,Ssex=?,Sage=?,Sdept=? where Sname=? and Ssex=?";
  PreparedStatement pstmt=conn.prepareStatement(sql);
  request.setCharacterEncoding("UTF-8");
  String id=request.getParameter("id");
  String name2=request.getParameter("name2");
  String sex2=request.getParameter("sex2");
  int age=Integer.parseInt(request.getParameter("age"));
  String sdept=request.getParameter("sdept");
  String name=(String)session.getAttribute("name");
  String sex=(String)session.getAttribute("sex");
  pstmt.setString(1,id); pstmt.setString(2,name2);
  pstmt.setString(3,sex2); pstmt.setInt(4,age);
  pstmt.setString(5,sdept); pstmt.setString(6,name);
  pstmt.setString(7,sex);
  int n=pstmt.executeUpdate();
  if(n>=1){%>重寫數(shù)據(jù)庫操作成功!br>%}
  else{%>重寫數(shù)據(jù)庫操作失敗!br>%}
  if(pstmt!=null){pstmt.close();}
  if(conn!=null){conn.close();}
 %>
 /body>
/html>

4.刪除記錄模塊

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
html>
 head> 
 title>條件刪除提交頁面/title>
 /head>
 body>
  請選擇刪除記錄條件hr width="100%" size="3">
  form action="studelete2.jsp" method="post">
  姓名:input type="text" name="name">br>br>
  性別:男input type="radio" value="男" name="sex">
  女input type="radio" value="女" name="sex">br>br>
  年齡范圍:br>p>
  最?。篿nput type="text" name="a1">br>
  最大:input type="text" name="a2">
  /p>
  input type="submit" value="提交">
  input type="reset" value="取消">

  /form>
 /body>
/html>

%@ page language="java" import="java.sql.*" pageEncoding="UTF-8"%>
html>
 head> 
 title>條件刪除處理頁面/title>
 /head> 
 body>
 % Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  String user="sa";
  String password="123456";
  String url="jdbc:sqlserver://localhost:1433;DatabaseName=p";
  Connection conn=DriverManager.getConnection(url,user,password);
  request.setCharacterEncoding("UTF-8");
  String name=request.getParameter("name");
  String sex=request.getParameter("sex");
  String ag1=request.getParameter("a1");
  String ag2=request.getParameter("a2");
  int a3,a4;
  String sql="delete from Student where Sname=? and Ssex=? and Sage>=? and Sage=?";
  PreparedStatement pstmt=conn.prepareStatement(sql);
  if(!name.equals("")) pstmt.setString(1,name);
  if(sex!=null) pstmt.setString(2,sex);
  if(!ag1.equals("")){a3=Integer.parseInt(ag1); pstmt.setInt(3,a3);}
  if(!ag2.equals("")){a4=Integer.parseInt(ag2); pstmt.setInt(4,a4);}
  int n=pstmt.executeUpdate();
  if(n==1){%>數(shù)據(jù)刪除成功br>%}
  else{%>數(shù)據(jù)刪除失敗!br>%}
  if(pstmt!=null){pstmt.close();}
  if(conn!=null){conn.close();}
 %>
 /body>
/html>

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • VueJS實現(xiàn)用戶管理系統(tǒng)
  • Node.js實現(xiàn)簡單管理系統(tǒng)
  • jdbc+jsp實現(xiàn)簡單員工管理系統(tǒng)
  • JSP實現(xiàn)簡單人事管理系統(tǒng)
  • JSP實現(xiàn)客戶信息管理系統(tǒng)
  • 詳解nodejs中express搭建權限管理系統(tǒng)
  • 基于jsp實現(xiàn)新聞管理系統(tǒng) 附完整源碼
  • 如何使用AngularJs打造權限管理系統(tǒng)【簡易型】
  • JSP學生信息管理系統(tǒng)
  • js實現(xiàn)車輛管理系統(tǒng)

標簽:大連 南京 黃石 銅川 廣州 內(nèi)江 貸款邀約 樂山

巨人網(wǎng)絡通訊聲明:本文標題《JSP學生信息管理系統(tǒng)設計》,本文關鍵詞  JSP,學生,信息,管理系統(tǒng),;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《JSP學生信息管理系統(tǒng)設計》相關的同類信息!
  • 本頁收集關于JSP學生信息管理系統(tǒng)設計的相關信息資訊供網(wǎng)民參考!
  • 推薦文章