javasql學生管理系統
⑴ 急求 java學生信息管理系統+sql 的 基於java窗口的
僅僅給你個參考//JavaGroupProject_StudentManagement源碼//NetBeansIDE6.5環境packagestudentmanager;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.io.*;importjava.util.*;classStudentimplementsjava.io.Serializable{Stringnumber,name,specialty,grade,borth,sex;publicStudent(){};publicvoidsetNumber(Stringnumber){this.number=number;}publicStringgetNumber(){returnnumber;}publicvoidsetName(Stringname){this.name=name;}publicStringgetName(){returnname;}publicvoidsetSex(Stringsex){this.sex=sex;}publicStringgetSex(){returnsex;}publicvoidsetSpecialty(Stringspecialty){this.specialty=specialty;}publicStringgetSpecialty(){returnspecialty;}publicvoidsetGrade(Stringgrade){this.grade=grade;}publicStringgetGrade(){returngrade;}publicvoidsetBorth(Stringborth){this.borth=borth;}publicStringgetBorth(){returnborth;}}{JLabellb=newJLabel("錄入請先輸入記錄,查詢、刪除請先輸入學號,修改是對查詢"+"內容改後的保存!");JTextField學號,姓名,專業,年級,出生;JRadioButton男,女;ButtonGroupgroup=null;JButton錄入,查詢,刪除,修改,顯示;JPanelp1,p2,p3,p4,p5,p6,pv,ph;Student學生=null;Hashtable學生散列表=null;Filefile=null;FileInputStreaminOne=null;ObjectInputStreaminTwo=null;FileOutputStreamoutOne=null;ObjectOutputStreamoutTwo=null;publicStudentManager(){super("學生基本信息管理系統");學號=newJTextField(10);姓名=newJTextField(10);專業=newJTextField(10);年級=newJTextField(10);出生=newJTextField(10);group=newButtonGroup();男=newJRadioButton("男",true);女=newJRadioButton("女",false);group.add(男);group.add(女);錄入=newJButton("錄入");查詢=newJButton("查詢");刪除=newJButton("刪除");修改=newJButton("修改");顯示=newJButton("顯示");錄入.addActionListener(newInputAct());查詢.addActionListener(newInquestAct());修改.addActionListener(newModifyAct());刪除.addActionListener(newDeleteAct());顯示.addActionListener(newShowAct());修改.setEnabled(false);p1=newJPanel();p1.add(newJLabel("學號:",JLabel.CENTER));p1.add(學號);p2=newJPanel();p2.add(newJLabel("姓名:",JLabel.CENTER));p2.add(姓名);p3=newJPanel();p3.add(newJLabel("性別:",JLabel.CENTER));p3.add(男);p3.add(女);p4=newJPanel();p4.add(newJLabel("專業:",JLabel.CENTER));p4.add(專業);p5=newJPanel();p5.add(newJLabel("年級:",JLabel.CENTER));p5.add(年級);p6=newJPanel();p6.add(newJLabel("出生:",JLabel.CENTER));p6.add(出生);pv=newJPanel();pv.setLayout(newGridLayout(6,1));pv.add(p1);pv.add(p2);pv.add(p3);pv.add(p4);pv.add(p5);pv.add(p6);ph=newJPanel();ph.add(錄入);ph.add(查詢);ph.add(修改);ph.add(刪除);ph.add(顯示);file=newFile("學生信息.txt");學生散列表=newHashtable();if(!file.exists()){try{FileOutputStreamout=newFileOutputStream(file);ObjectOutputStreamobjectOut=newObjectOutputStream(out);objectOut.writeObject(學生散列表);objectOut.close();out.close();}catch(IOExceptione){}}Containercon=getContentPane();con.setLayout(newBorderLayout());con.add(lb,BorderLayout.NORTH);con.add(pv,BorderLayout.CENTER);con.add(ph,BorderLayout.SOUTH);setDefaultCloseOperation(EXIT_ON_CLOSE);setBounds(100,100,600,300);setVisible(true);}publicstaticvoidmain(String[]args){newStudentManager();}{publicvoidactionPerformed(ActionEvente){修改.setEnabled(false);Stringnumber="";number=學號.getText();if(number.length()>0){try{inOne=newFileInputStream(file);inTwo=newObjectInputStream(inOne);學生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exceptionee){System.out.println("創建散列表出現問題!");}if(學生散列表.containsKey(number)){Stringwarning="該生信息已存在,請到修改頁面修改!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}//endif1else{Stringm="該生信息將被錄入!";intok=JOptionPane.showConfirmDialog(null,m,"確認",JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);if(ok==JOptionPane.YES_OPTION){Stringname=姓名.getText();Stringspecialty=專業.getText();Stringgrade=年級.getText();Stringborth=出生.getText();Stringsex=null;if(男.isSelected()){sex=男.getText();}else{sex=女.getText();}學生=newStudent();學生.setNumber(number);學生.setName(name);學生.setSpecialty(specialty);學生.setGrade(grade);學生.setBorth(borth);學生.setSex(sex);try{outOne=newFileOutputStream(file);outTwo=newObjectOutputStream(outOne);學生散列表.put(number,學生);outTwo.writeObject(學生散列表);outTwo.close();outOne.close();}catch(Exceptionee){System.out.println("輸出散列表出現問題!");}學號.setText(null);姓名.setText(null);專業.setText(null);年級.setText(null);出生.setText(null);}}//endelse1}//endif0else{Stringwarning="必須輸入學號!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}//endelse0}//endactionPerformed}//{publicvoidactionPerformed(ActionEvente){Stringnumber="";number=學號.getText();if(number.length()>0){try{inOne=newFileInputStream(file);inTwo=newObjectInputStream(inOne);學生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exceptionee){System.out.println("散列表有問題!");}if(學生散列表.containsKey(number)){修改.setEnabled(true);Studentstu=(Student)學生散列表.get(number);姓名.setText(stu.getName());專業.setText(stu.getSpecialty());年級.setText(stu.getGrade());出生.setText(stu.getBorth());if(stu.getSex().equals("男")){男.setSelected(true);}else{女.setSelected(true);}}else{修改.setEnabled(false);Stringwarning="該學號不存在!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}}else{修改.setEnabled(false);Stringwarning="必須輸入學號!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}}}{publicvoidactionPerformed(ActionEvente){Stringnumber=學號.getText();Stringname=姓名.getText();Stringspecialty=專業.getText();Stringgrade=年級.getText();Stringborth=出生.getText();Stringsex=null;if(男.isSelected()){sex=男.getText();}else{sex=女.getText();}Student學生=newStudent();學生.setNumber(number);學生.setName(name);學生.setSpecialty(specialty);學生.setGrade(grade);學生.setBorth(borth);學生.setSex(sex);try{outOne=newFileOutputStream(file);outTwo=newObjectOutputStream(outOne);學生散列表.put(number,學生);outTwo.writeObject(學生散列表);outTwo.close();outOne.close();學號.setText(null);姓名.setText(null);專業.setText(null);年級.setText(null);出生.setText(null);}catch(Exceptionee){System.out.println("錄入修改出現異常!");修改.setEnabled(false);}}}{publicvoidactionPerformed(ActionEvente){修改.setEnabled(false);Stringnumber=學號.getText();if(number.length()>0){try{inOne=newFileInputStream(file);inTwo=newObjectInputStream(inOne);學生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exceptionee){}if(學生散列表.containsKey(number)){Studentstu=(Student)學生散列表.get(number);姓名.setText(stu.getName());專業.setText(stu.getSpecialty());年級.setText(stu.getGrade());出生.setText(stu.getBorth());if(stu.getSex().equals("男")){男.setSelected(true);}else{女.setSelected(true);}}Stringm="確定要刪除該學生的記錄嗎?";intok=JOptionPane.showConfirmDialog(null,m,"確認",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);if(ok==JOptionPane.YES_OPTION){學生散列表.remove(number);try{outOne=newFileOutputStream(file);outTwo=newObjectOutputStream(outOne);outTwo.writeObject(學生散列表);outTwo.close();outOne.close();學號.setText(null);姓名.setText(null);專業.setText(null);年級.setText(null);出生.setText(null);}catch(Exceptionee){System.out.println(ee);}}elseif(ok==JOptionPane.NO_OPTION){學號.setText(null);姓名.setText(null);專業.setText(null);年級.setText(null);出生.setText(null);}else{Stringwarning="該學號不存在!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}}else{Stringwarning="必須輸入學號!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}}}{publicvoidactionPerformed(ActionEvente){newStudentShow(file);}}{Hashtable學生散列表=null;JTextArea顯示=null;FileInputStreaminOne=null;ObjectInputStreaminTwo=null;Filefile=null;publicStudentShow(Filefile){super(newJFrame(),"顯示對話框");this.file=file;顯示=newJTextArea(16,30);try{inOne=newFileInputStream(file);inTwo=newObjectInputStream(inOne);學生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exceptionee){}if(學生散列表.isEmpty())顯示.append("目前還沒有學生的信息記錄!\n");else{顯示.setText("學號姓名性別專業年級出生\n");for(Enumerationenm=學生散列表.elements();enm.hasMoreElements();){Studentstu=(Student)enm.nextElement();Stringsex="";if(stu.getSex().equals("男"))sex="男";elsesex="女";Stringstr=stu.getNumber()+","+stu.getName()+","+sex+","+stu.getSpecialty()+","+stu.getGrade()+","+stu.getBorth()+"\n";顯示.append(str);}}JScrollPanescroll=newJScrollPane(顯示);Containercon=getContentPane();con.add("Center",scroll);con.validate();setVisible(true);setBounds(200,200,400,300);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){setVisible(false);}});}}}
⑵ 怎樣用java和sql來做一個學生管理系統
關於介紹做系統的書是很少的,大部分書都是介紹基礎知識,建議從網上down一個學生管理系統的源代碼,然後看別人怎麼做的,自己再學著做。
要看書的話,兩本就夠了,一本Java基礎,一本SQL基礎,具體書目,隨便,因為介紹基礎的書都差不多
⑶ 如何用java製作學生管理系統
是要小型的還是大型的 小型的 需要資料庫嗎?下面這是個 控制台輸出的
importjava.util.List;
importjava.util.Scanner;
importcn.com.shxt.DBUtils.JdbcTool;
publicclassStudentManager{
/*
1.學生信息管理系統,界面如下
1--學生信息添加
2--全部學生信息查詢
3--查詢錄取學生的信息
4--按學號查詢錄取學生的信息
5--按姓名查詢錄取學生的信息
6--退出
*/
publicstaticvoidmain(String[]args){
Scannerscan=newScanner(System.in);
JdbcTooljt=newJdbcTool();
List<List<String>>tableList;
intflag;
Stringno;
Stringname;
Stringmain;
Stringpolitics;
StringEnglish;
StringMath;
StringMajor;
StringTotal;
Stringsql;
booleanpanan=true;
while(panan){
System.out.println();
System.out.println("===========歡迎進入研究生錄取系統================");
System.out.println("1--學生信息添加");
System.out.println("2--錄入學生信息查詢");
System.out.println("3--查詢錄取學生的信息");
System.out.println("4--按學號查詢錄取學生的信息");
System.out.println("5--按姓名查詢錄取學生的信息");
System.out.println("0--退出");
System.out.println("請輸入序號,選擇功能");
flag=scan.nextInt();
switch(flag){
case1:
System.out.println("請輸入學生的學號、姓名、報考專業、政治、英語、高數、專業課分數");
no=scan.next();
name=scan.next();
main=scan.next();
politics=scan.next();
English=scan.next();
Math=scan.next();
Major=scan.next();
inttotal=0;
total=Integer.parseInt(politics)+Integer.parseInt(English)+Integer.parseInt(Math)+Integer.parseInt(Major);
sql="insertintostumanager(s_no,s_name,s_main,s_politics,s_English,s_Math,s_Major,s_Total)values('"+no+"','"+name+"','"+main+"',"+politics+",'"+English+"','"+Math+"','"+Major+"','"+total+"')";
jt.update(sql);
System.out.println("添加成功");
break;
case2:
sql="select*fromstumanagerorderbys_totaldesc";
tableList=jt.query(sql);
if(tableList!=null&&tableList.size()>0){
tableList=jt.query(sql);
for(List<String>rowList:tableList){
System.out.println("id 學號 姓名 專業 政治 英語 高數 專業 總分 ");
System.out.println(rowList.get(0)+" "+rowList.get(1)+" "+rowList.get(2)+" "+rowList.get(3)+" "+rowList.get(4)+" "+rowList.get(5)+" "+rowList.get(6)+" "+rowList.get(7)+" "+rowList.get(8));
}
}else{
System.out.println("沒有學生信息,請添加~~");
break;
}
break;
case3:
System.out.println("請輸入報考專業以及政治、英語、高數、專業課、總分的分數");
main=scan.next();
politics=scan.next();
English=scan.next();
Math=scan.next();
Major=scan.next();
Total=scan.next();
sql="select*fromstumanagerwheres_main='"+main+"'ands_politics>="+politics+"ands_English>="+English+"ands_Math>="+Math+"ands_Major>="+Major+"ands_Total>="+Total+"";
tableList=jt.query(sql);
if(tableList.size()!=0){
tableList=jt.query(sql);
for(List<String>rowList:tableList){
System.out.println("id 學號 姓名 專業 政治 英語 高數 專業 總分 ");
System.out.println(rowList.get(0)+" "+rowList.get(1)+" "+rowList.get(2)+" "+rowList.get(3)+" "+rowList.get(4)+" "+rowList.get(5)+" "+rowList.get(6)+" "+rowList.get(7)+" "+rowList.get(8));
System.out.println("恭喜你,你被錄取了");
}
}else{
System.out.println("抱歉,你沒有被錄取");
break;
}
break;
case4:
System.out.println("請輸入要查詢的學生的學號以及政治、英語、高數、專業課、總分的錄取分數");
no=scan.next();
politics=scan.next();
English=scan.next();
Math=scan.next();
Major=scan.next();
Total=scan.next();
System.out.println("此學生的信息:");
sql="select*fromstumanagerwheres_politics>="+politics+"ands_English>="+English+"ands_Math>="+Math+"ands_Major>="+Major+"ands_Total>="+Total+"ands_no="+no+"";
tableList=jt.query(sql);
if(tableList!=null&&tableList.size()>0){
tableList=jt.query(sql);
for(List<String>rowList:tableList){
System.out.println("id 學號 姓名 專業 政治 英語 高數 專業 總分 ");
System.out.println(rowList.get(0)+" "+rowList.get(1)+" "+rowList.get(2)+" "+rowList.get(3)+" "+rowList.get(4)+" "+rowList.get(5)+" "+rowList.get(6)+" "+rowList.get(7)+" "+rowList.get(8));
System.out.println("恭喜你,你被錄取了");
}
}else{
System.out.println("抱歉,你沒有被錄取");
break;
}
break;
case5:
System.out.println("請輸入要查詢的學生姓名(單個文字也可)以及政治、英語、高數、專業課、總分的錄取分數");
name=scan.next();
politics=scan.next();
English=scan.next();
Math=scan.next();
Major=scan.next();
Total=scan.next();
sql="select*fromstumanagerwheres_politics>="+politics+"ands_English>="+English+"ands_Math>="+Math+"ands_Major>="+Major+"ands_Total>="+Total+"ands_namelike'%"+name+"%'";
tableList=jt.query(sql);
if(tableList!=null&&tableList.size()>0){
tableList=jt.query(sql);
for(List<String>rowList:tableList){
System.out.println("id 學號 姓名 專業 政治 英語 高數 專業 總分 ");
System.out.println(rowList.get(0)+" "+rowList.get(1)+" "+rowList.get(2)+" "+rowList.get(3)+" "+rowList.get(4)+" "+rowList.get(5)+" "+rowList.get(6)+" "+rowList.get(7)+" "+rowList.get(8));
System.out.println("恭喜你,你被錄取了");
}
}else{
System.out.println("抱歉,你沒有被錄取");
break;
}
break;
case0:
panan=false;
break;
}
}
}
}
⑷ 怎麼用java+sql資料庫做一個學生信息管理系統
Student 類
public class Student
{
private int id;
private int age;
private int score;
private String name;
public Student()
{
}
public Student(int id, int age, int score, String name)
{
this.id = id;
this.age = age;
this.score = score;
this.name = name;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public int getScore()
{
return score;
}
public void setScore(int score)
{
this.score = score;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
@Override
public String toString()
{
return "學號:" + id + " 姓名:" + name + " 年齡:" + age + " 成績:" + score;
}
}
Manager類
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Manager
{
private List<Student> list;
public Manager(List<Student> list)
{
this.list = list;
}
public List<Student> getList()
{
return list;
}
public void setList(List<Student> list)
{
this.list = list;
}
//添加學生
public void add(Student s)
{
list.add(s);
}
//根據學生學號返回學生年齡
public int search(int id)
{
for(Iterator<Student> iter = list.iterator(); iter.hasNext();)
{
Student s = iter.next();
if(s.getId() == id)
{
return s.getAge();
}
}
return -1;
}
//刪除學生
public void remove(int id)
{
for(Iterator<Student> iter = list.iterator(); iter.hasNext();)
{
Student s = iter.next();
if(s.getId() == id)
{
list.remove(s);
}
}
}
//計算總成績
public int allScore()
{
int score = 0;
int temp = 0;
for(Iterator<Student> iter = list.iterator(); iter.hasNext();)
{
Student s = iter.next();
temp = s.getScore();
score += temp;
}
return score;
}
//修改成績
public void update(int id)
{
for(Iterator<Student> iter = list.iterator(); iter.hasNext();)
{
Student s = iter.next();
if(s.getId() == id)
{
s.setScore(s.getScore() + 10);
}
}
}
}
測試類 Client
import java.util.ArrayList;
import java.util.List;
public class Client
{
public static void main(String[] args)
{
List<Student> list = new ArrayList<Student>();
Manager manager = new Manager(list);//創建一個管理者
Student s1 = new Student();//無參構造方法創建的學生實例
//通過方法設置s1的屬性
s1.setId(201105);
s1.setAge(20);
s1.setScore(100);
s1.setName("zhangsan");
Student s2 = new Student(201101,21,98,"lisi");//通過帶參數的構造方法創建實例
Student s3 = new Student(201108,25,95,"zhaoliu");
Student s4 = new Student(201110,23,80,"xiaoming");
Student s5 = new Student(201106,28,78,"hello");
//放到集合當中
manager.getList().add(s1);//添加學生
manager.getList().add(s2);
manager.getList().add(s3);
manager.getList().add(s4);
manager.getList().add(s5);
System.out.println(list);
System.out.println(manager.allScore());
System.out.println(manager.search(201110));//根據學生學號查詢學生年齡
manager.remove(201110);//刪除學生
manager.update(201101);//修改成績
}
}
可以完成你上述的基本要求,如果改動可以自行修改 很簡單。
⑸ 哪位高手能幫忙做個JAVA+SQL的學生信息管理系統
只有管理員登陸的!
鏈接資料庫:
package score.db;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
public class DBUtil {
//載入驅動
private static String driverName=null;
private static String connUrl=null;
private static String user=null;
private static String password=null;
private static Connection conn=null;
private static ResultSet rs=null;
private static Statement stm=null;
static
{
InputStream ips=null;
try
{
ips=DBUtil.class.getResourceAsStream("DBConfig.properties");
Properties prop=new Properties();
prop.load(ips);
driverName=prop.getProperty("driverName");
connUrl=prop.getProperty("connUrl");
user=prop.getProperty("user");
password=prop.getProperty("password");
System.out.println("start to SQL driver");
ips.close();
}catch(Exception e)
{
e.getStackTrace();
}
finally
{
if(ips!=null)
{
try
{
ips.close();
}catch(Exception e)
{
ips=null;
}
}
}
}
//獲取資料庫連接
public static Connection getConnection() throws ClassNotFoundException, SQLException
{
Class.forName(driverName);
conn=DriverManager.getConnection(connUrl,user,password);
return conn;
}
//數據查詢
public static ResultSet queryData(String sql) throws ClassNotFoundException
{
Statement stm=null;
try
{
conn=getConnection();
stm=conn.createStatement();
rs=stm.executeQuery(sql);
}catch(SQLException e)
{
e.printStackTrace();
}
return rs;
}
// 數據更新
public static int Update(String sql) throws ClassNotFoundException
{ int a=0;
try {
conn=getConnection();
stm=conn.createStatement();
a=stm.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return a;
}
//關閉資料庫
public static void closeConnection()
{
if(rs!=null)
{
try {
rs.close();
} catch (SQLException e) {
rs=null;
}
}
if(stm!=null)
{
try {
stm.close();
} catch (SQLException e) {
stm=null;
}
}
if(conn!=null)
{
try {
conn.close();
} catch (SQLException e) {
conn=null;
}
}
}
}
JAVABEAN:
package score.bean;
public class userInfoBean {
String userCode;
String userPwd;
String userFlag;
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public String getUserPwd() {
return userPwd;
}
public void setUserPwd(String userPwd) {
this.userPwd = userPwd;
}
public String getUserFlag() {
return userFlag;
}
public void setUserFlag(String userFlag) {
this.userFlag = userFlag;
}
}
登陸Login:
package score.java;
import java.sql.Connection;
import java.sql.ResultSet;
import score.db.DBUtil;
public class Login {
//登陸方法
public String login(String userpwd,String userCode)
{
Connection conn=null;
ResultSet rs=null;
String userflag=null;
String pwd=null;
System.out.println("test1");
//載入資料庫
DBUtil db=new DBUtil();
try
{
conn=db.getConnection();
System.out.println("test2");
String sql="select userPwd,userFlag from tab_user where userCode='"+userCode+"'";
rs=db.queryData(sql);
while(rs.next())
{
pwd=rs.getString("userPwd");
userflag=rs.getString("userFlag");
}
db.closeConnection();
}catch(Exception e){}
if(userpwd.equals(pwd)&&userflag.equals("M"))
return "M";
else if(userpwd.equals(pwd)&&userflag.equals("T"))
return "T";
else if(userpwd.equals(pwd)&&userflag.equals("S"))
return "S";
else return "E";
}
}
LoginServlet:
package score.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import score.db.DBUtil;
import score.java.Login;
public class LoginServlet extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=GBK");
request.setCharacterEncoding("GBK");
//獲取表單信息
String usercode=request.getParameter("userCode");
String userpwd=request.getParameter("userPwd");
System.out.println("xxx");
//創建業務類Login的一個對象
Login login=new Login();
//轉發跳轉
if(login.login(userpwd,usercode).equals("M"))
{
getServletContext().getRequestDispatcher("/manager/Manage.jsp").forward(request, response);
}
else if(login.login(userpwd,usercode).equals("S"))
{
getServletContext().getRequestDispatcher("/student/stuManage.jsp").forward(request, response);
}
else if(login.login(userpwd,usercode).equals("T"))
{
getServletContext().getRequestDispatcher("/teacher/teaManage.jsp").forward(request, response);
}
}
}
⑹ 臨近畢業,用java做了個學生信息管理系統,需要用到sql資料庫,請問怎麼連接,急用,謝謝各位
package test;
import java.sql.*;
import cn.com.sdata.util.SDGetConnection;
/**
*
* @author user
*mssql資料庫連接操作
*/
public class MssqlConnTest {
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; //載入JDBC驅動
String dbURL = "jdbc:sqlserver://127.0.0.1:1433; DatabaseName=test"; //連接伺服器和資料庫sample
String userName = "sa"; //默認用戶名
String userPwd = "000000"; //密碼
Connection dbConn;
public Connection getConnection()
{
try
{
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("Connection Successful!"); //如果連接成功 控制台輸出Connection Successful!
return dbConn;
} catch (Exception e)
{
e.printStackTrace();
}
return null;
}
public void closeConnection()
{
try {
dbConn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] srg)
{
// DBConnectionManager DBConnectionManager1 = new DBConnectionManager();
try
{
System.out.println("success");
MssqlConnTest test = new MssqlConnTest();
Connection conn = test.getConnection();
System.out.println("Connection Successful!"); //如果連接成功 控制台輸出Connection Successful!
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select top 1 * from DOI");
while(rs.next())
{
System.out.print("\tfirst: "+rs.getString(1));
System.out.print("\tsecond: "+rs.getString(2));
}
//*/
}catch(Exception e)
{
e.printStackTrace();
}
}
}
⑺ 用java做一個學生成績管理系統需要哪些技術
用java做一個學生成績管理系統,可以用到如下技術:
後台:ssh框架,不用框架的話,單純地用jsp
+
servlet也可以。
前台:html
+
css
+
js
+
jquery
資料庫:掌握sql語言的編寫,資料庫的連接。復雜的項目還需要用到存儲過程。