JAVA数据库课程设计-学生选课管理系统的


    

    课程设计目
    通次设计做出型理系统加强JAVA学知识巩固融会贯通说学期学知识结加深JAVA数库理解

    二需求分析
    功需求分析:
    该系统具备理学生信息课程信息选课信息功:户通输入账号密码进该系统进行基础维护(学生信息维护课程信息维护选课信息维护)全部进行增加修改删模糊查询

    三数项:

    1表admin(户表)
    Field
    Type
    Null
    Key
    Comment
    Username
    char(10)
    ——
    PRI
    户名
    password
    char(10)
    ——
    ——
    密码
    Name
    Char(10)
    ——
    ——
    户昵称

    2表S(学生信息表)
    Field
    Type
    Null
    Key
    Comment
    Sno
    nvarchar(50)
    ——
    PRI
    学号
    Sname
    nvarchar(50)
    ——
    ——
    姓名
    Sx
    nvarchar(50)
    ——
    ——


    3表C(课程信息表)
    Field
    Type
    Null
    Key
    Comment
    Cno
    nvarchar(50)
    ——
    PRI
    课号
    Cname
    nvarchar(50)
    ——
    ——
    课名



    4表SC(学生信息表)
    Field
    Type
    Null
    Key
    Comment
    Cno
    nvarchar(50)
    ——
    PRI
    课号
    Sno
    nvarchar(50)
    ——
    PRI
    学号
    C
    nvarchar(50)
    ——
    ——
    成绩


    四系统功描述
    该型系统理学生课程基信息功包括四方面:
    1理学生信息中包括添加删修改等操作
    2理课程信息中包括添加删修改等操作
    3理选课信息中包括添加删修改等操作
    4查询信息中包括查询学生信息查询课程信息查询选课信息等操作

    选课信息
    课程信息
    学生信息
    删信息
    修改信息
    添加信息
    删信息
    修改信息
    添加信息
    删信息
    修改信息
    添加信息
    查询理
    选课理
    课程理
    学生理
    学生信息理系统


























    五代码分析
    连接数库方法:
    java连接数库驱动关数库操作
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test处student数库名
    String userName sa 默认户名
    String userPwd mima 密码
    Connection dbConnnull
    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful)
    果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()}
    return dbConn}
    户登录界面userjava:
    登录时账号密码未填写输入错误账号密码会提出错误提示框填写账号密码会读取数库里admin表查询输入否存误登录户界面
    public class User extends JFrame{
    private JLabel usepassword
    private JTextField k1户名输入框
    private JPasswordField k2密码输入框
    private JButton b1b2
    登录窗口
    public User(JFrame f){
    super(系统登录)
    Container cgetContentPane()
    csetLayout(new FlowLayout())
    usenew JLabel(username)
    usesetFont(new Font(SerifFontPLAIN20))
    passwordnew JLabel(password)
    passwordsetFont(new Font(SerifFontPLAIN20))
    k1new JTextField(12)
    k2new JPasswordField(12)
    b1new JButton(登录)
    b2new JButton(退出)
    设置登录方法
    BHandler bnew BHandler()
    EXIT dnew EXIT()
    b1addActionListener(b)
    b2addActionListener(d)
    添加控件
    cadd(use)
    cadd(k1)
    cadd(password)
    cadd(k2)
    cadd(b1)
    cadd(b2)
    setBounds(600300250150)
    setVisible(true)
    setResizable(false)
    setDefaultCloseOperation(JFrameEXIT_ON_CLOSE)}
    函数
    public static void main(String[] args) {
    User f1new User(new JFrame())}
    效果图:

    户界面:Menujava
    户界面菜单栏4级菜单学生理课程理选课理添加修改删数分操作数库里S表(学生)C表(课程)SC表(选课)查询理进行三表查询
    import javaawt*
    import javaawtevent*
    import javaxswing*
    public class Menu extends JFrame implements ActionListener{
    Addstu 增加学生界面
    Updatastu 修改学生界面
    Delstu 删学生界面
    AddC 增加课程界面
    DelC 删课程界面
    UpdateC 修改课程界面
    AddSC 增加选课界面
    DelSC 删选课界面
    UpdateSC 修改选课界面
    Selstu 学生查询界面
    JPanel pCenter
    CardLayout cardnull
    JLabel labelnull
    JMenuBar mbnew JMenuBar()菜单栏
    JMenu m1new JMenu(学生理)
    JMenuItem add1new JMenuItem(add1 )
    JMenuItem updata1new JMenuItem(updata1 )
    JMenuItem delete1new JMenuItem(delete1 )
    JMenu m2new JMenu(课程理)
    JMenuItem add2new JMenuItem(add2 )
    JMenuItem updata2new JMenuItem(updata2 )
    JMenuItem delete2new JMenuItem(delete2 )
    JMenu m3new JMenu(选课理)
    JMenuItem add3new JMenuItem(add3 )
    JMenuItem updata3new JMenuItem(updata3 )
    JMenuItem delete3new JMenuItem(delete3 )
    JMenu m4new JMenu(查询理)
    JMenuItem 学生查询new JMenuItem(查询信息 )
    JMenuItem m5new JMenuItem(系统退出)
    Font tnew Font (sanerifFontPLAIN12)
    public Menu (){
    thissetTitle(学生选课理系统)
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}
    组合菜单
    addMenu1()
    addMenu2()
    addMenu3()
    addMenu4()
    addJMenuBar()
    setJMenuBar(mb)
    labelnew JLabel(选课理系统JLabelCENTER)
    labelsetFont(new Font(宋体FontBOLD36))
    labelsetHorizontalTextPosition(SwingConstantsCENTER)
    labelsetForeground(Colorred)
    点击事件
    add1addActionListener(this)
    updata1addActionListener(this)
    delete1addActionListener(this)
    m5addActionListener(this)
    add2addActionListener(this)
    delete2addActionListener(this)
    updata2addActionListener(this)
    add3addActionListener(this)
    delete3addActionListener(this)
    updata3addActionListener(this)
    学生查询addActionListener(this)
    cardnew CardLayout()
    pCenternew JPanel()
    pCentersetLayout(card)
    增加学生界面new Addstu()
    修改学生界面new Updatastu()
    删学生界面new Delstu()
    增加课程界面new AddC()
    删课程界面new DelC()
    修改课程界面new UpdateC()
    增加选课界面new AddSC()
    删选课界面new DelSC()
    修改选课界面new UpdateSC()
    学生查询界面new Selstu()
    pCenteradd(欢迎界面label)
    pCenteradd(增加学生界面增加学生界面)
    pCenteradd(修改学生界面修改学生界面)
    pCenteradd(删学生界面删学生界面)
    pCenteradd(增加课程界面增加课程界面)
    pCenteradd(删课程界面删课程界面)
    pCenteradd(修改课程界面修改课程界面)
    pCenteradd(增加选课界面增加选课界面)
    pCenteradd(删选课界面删选课界面)
    pCenteradd(修改选课界面修改选课界面)
    pCenteradd(学生查询界面 学生查询界面)
    add(pCenterBorderLayoutCENTER)
    validate()
    setVisible(true)
    setBounds(400150400280)
    setDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
    addWindowListener(new WindowAdapter(){关闭程序时操作
    public void windowClosing(WindowEvent e){Systemexit(0)} })
    validate()}
    private void addJMenuBar() {
    mbadd(m1)mbadd(m2)mbadd(m3)mbadd(m4)mbadd(m5)}
    private void addMenu4() {
    m4add(学生查询)m4setFont(t)}
    private void addMenu3() {
    m3add(add3)m3add(updata3)m3add(delete3)m3setFont(t) }
    private void addMenu2() {菜单加入菜单栏中
    m2add(add2)m2add(updata2)m2add(delete2)m2setFont(t) }
    private void addMenu1() {
    m1add(add1)m1add(updata1)m1add(delete1)m1setFont(t) }
    public void actionPerformed(ActionEvent e){
    Object objegetSource()
    if(objm5){Systemexit(0)}
    else{if(objadd1){cardshow(pCenter增加学生界面)}
    else{if(objupdata1){ cardshow(pCenter修改学生界面)}
    else{if(objdelete1){ cardshow(pCenter 删学生界面)}
    else{if(objadd2){ cardshow(pCenter 增加课程界面)}
    else{if(objdelete2){ cardshow(pCenter 删课程界面)}
    else{if(objupdata2){ cardshow(pCenter 修改课程界面)}
    else{if(objadd3){ cardshow(pCenter 增加选课界面)}
    else{if(objdelete3){ cardshow(pCenter 删选课界面)}
    else{if(objupdata3){ cardshow(pCenter 修改选课界面)}
    else{if(obj学生查询){ cardshow(pCenter 学生查询界面)
    }}}}}}}}}}}}
    public static void main(String[] args) {new Menu()}}
    效果图:

    添加界面AddCjavaAddSCjavaAddstujava
    添加数时遇必须信息未填写重复信息数库中已存会提示法添加错误原
    import javaawt*
    import javaxswing*
    import javasql*
    import javaawtevent*

    public class AddC extends JPanel implements ActionListener{
    JTextField 课号课名
    JButton 录入

    public AddC(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}catch(Exception e){Systemerrprintln(设置外观 +e)}
    课号new JTextField(12)
    课名new JTextField(12)
    录入new JButton(录入)
    录入addActionListener(this)
    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    box1add(new JLabel(课号))
    box1add(课号)
    box2add(new JLabel(课名))
    box2add(课名)
    box4add(录入)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())
    JPanel messPanelnew JPanel()
    messPaneladd(boxH)
    setLayout(new BorderLayout())
    add(messPanelBorderLayoutCENTER)
    validate()}
    效果图:

    添加界面UpdateCjavaUpdateSCjava Updatestujava
    先查找想修改项目修改信息包括号码(学号课号)会进行查询果修改号码已存修改必须信息变成空会提示法修改错误原外修改C表S表会连SC表中应信息起修改
    import javaawt*
    import javaawtevent*
    import javasql*
    import javaxswing*
    public class UpdateC extends JPanel implements ActionListener{
    String savenull
    JTextField 课号1课号课名
    JButton 修改查找
    public UpdateC(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}catch(Exception e){Systemerrprintln(设置外观 +e)}
    课号1new JTextField(12)
    课号new JTextField(12)
    课名new JTextField(12)
    修改new JButton(修改)
    查找new JButton(查找)
    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    box1add(new JLabel(课号JLabelCENTER))
    box1add(课号)
    box2add(new JLabel(课名JLabelCENTER))
    box2add(课名)
    box3add(修改)
    box5add(new JLabel(课号JLabelCENTER))
    box5add(课号1)
    box5add(查找)
    修改addActionListener(this)
    查找addActionListener(this)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())
    JPanel picPanelnew JPanel()
    JPanel messPanelnew JPanel()
    messPaneladd(box5)
    picPaneladd(boxH)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    validate()}

    删界面DelCjavaDelSCjava Deltujava
    先查找想删项目然删外删C表S表容会连SC表中应信息起修改
    import javaawt*
    import javaawtevent*
    import javasql*
    import javaxswing*
    public class DelC extends JPanel implements ActionListener{
    String savenull
    JTextField 课号1课号课名
    JButton 删查找
    public DelC(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}catch(Exception e){Systemerrprintln(设置外观 +e)}
    课号1new JTextField(12)
    课号new JTextField(12)
    课名new JTextField(12)
    删new JButton(删)
    查找new JButton(查找)
    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    box1add(new JLabel(课号JLabelCENTER))
    box1add(课号)
    box2add(new JLabel(课名JLabelCENTER))
    box2add(课名)
    box4add(删)
    box5add(new JLabel(课号JLabelCENTER))
    box5add(课号1)
    box5add(查找)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())
    删addActionListener(this)
    查找addActionListener(this)
    JPanel picPanelnew JPanel()
    JPanel messPanelnew JPanel()
    messPaneladd(box5)
    picPaneladd(boxH)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    validate()}

    查询界面Selstojava
    意条件模糊查找相关表
    import javaawt*
    import javaawtevent*
    import javasql*
    import javaxswing*
    public class Selstu extends JPanel implements ActionListener{
    JTextField 学号姓名系
    JButton 查找
    JTextField 课号课名
    JButton 查找1
    JTextField 课号1学号1成绩
    JButton 查找2
    public Selstu (){
    学号new JTextField(12)
    姓名new JTextField(12)
    系new JTextField(12)
    课号new JTextField(12)
    课名new JTextField(12)
    课号1new JTextField(12)
    学号1new JTextField(12)
    成绩new JTextField(12)
    查找new JButton(查找学生信息)
    查找1new JButton(查找课程信息)
    查找2new JButton(查找选课信息)
    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    Box box6BoxcreateHorizontalBox()
    Box box7BoxcreateHorizontalBox()
    box1add(new JLabel(学号JLabelCENTER))
    box1add(学号)
    box1add(new JLabel(姓名JLabelCENTER))
    box1add(姓名)
    box1add(new JLabel(系JLabelCENTER))
    box1add(系)
    box2add(查找)
    box4add(new JLabel(课号JLabelCENTER))
    box4add(课号)
    box4add(new JLabel(课名JLabelCENTER))
    box4add(课名)
    box6add(查找1)
    box5add(new JLabel(课号JLabelCENTER))
    box5add(课号1)
    box5add(new JLabel(学号JLabelCENTER))
    box5add(学号1)
    box5add(new JLabel(成绩JLabelCENTER))
    box5add(成绩)
    box7add(查找2)
    Box boxH1BoxcreateVerticalBox()竖放box
    boxH1add(box1)
    boxH1add(box2)
    boxH1add(BoxcreateVerticalGlue())
    Box boxH2BoxcreateVerticalBox()竖放box
    boxH2add(box4)
    boxH2add(box6)
    boxH2add(BoxcreateVerticalGlue())
    Box boxH3BoxcreateVerticalBox()竖放box
    boxH3add(box5)
    boxH3add(box7)
    boxH3add(BoxcreateVerticalGlue())
    查找addActionListener(this)
    查找1addActionListener(this)
    查找2addActionListener(this)
    JPanel messPanelnew JPanel()
    JPanel picPanelnew JPanel()
    JPanel threePanelnew JPanel()
    messPaneladd(boxH1)
    picPaneladd(boxH2)
    threePaneladd(boxH3)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    JSplitPane splitV1new JSplitPane(JSplitPaneVERTICAL_SPLITsplitVthreePanel)分割
    add(splitV1BorderLayoutCENTER)
    validate()}
    效果图:






    面java源代码总15类分AddCjavaAddSCjavaAddstujava DelstujavaDelCjava DelSCjavaMenujavaSelCjavaSelSCjavaSelstujavaStudentjavaUpdatastujavaUpdateCjavaUpdateSCjavaUserjava
    太懒类名错误没修改没优化系统总算运行数库sql2005果数库改驱动具体网百度吧果空优化滴……

    AddCjaba:

    import javaawt*
    import javaxswing*
    import javasql*
    import javaawtevent*

    public class AddC extends JPanel implements ActionListener{
    JTextField 课号课名
    JButton 录入

    public AddC(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}

    课号new JTextField(12)
    课名new JTextField(12)
    录入new JButton(录入)
    录入addActionListener(this)

    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    box1add(new JLabel(课号))
    box1add(课号)
    box2add(new JLabel(课名))
    box2add(课名)
    box4add(录入)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())
    JPanel messPanelnew JPanel()
    messPaneladd(boxH)
    setLayout(new BorderLayout())
    add(messPanelBorderLayoutCENTER)
    validate()
    }
    public void actionPerformed(ActionEvent c){
    Object objcgetSource()
    if(obj录入){
    if(课号getText()equals()||课名getText()equals()){
    JOptionPaneshowMessageDialog(this学生信息请填满录入 )
    }
    Statement stmtnull
    ResultSet rsnullrs1null
    String sqlsql1
    sql1select * from C where Cno'+课号getText()+'
    sqlinsert into C values('+课号getText()+''+课名getText()+')
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){JOptionPaneshowMessageDialog(this该课号存法添加)}
    else{
    stmtexecuteUpdate(sql)
    JOptionPaneshowMessageDialog(this添加成功)
    }
    rs1close()

    stmtclose()
    }
    catch(SQLException e){
    Systemoutprint(SQL Exception occurMessage is+egetMessage())
    }
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }

    }



    AddSCjava:

    import javaawt*

    import javaxswing*

    import javasql*
    import javautil*
    import javaxswingfilechooser*
    import javaio*
    import javaawtevent*

    public class AddSC extends JPanel implements ActionListener{
    JTextField 课号学号成绩
    JButton 录入

    public AddSC(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}

    课号new JTextField(12)
    学号new JTextField(12)
    成绩new JTextField(12)
    录入new JButton(录入)
    录入addActionListener(this)

    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    box1add(new JLabel(课号))
    box1add(课号)
    box2add(new JLabel(学号))
    box2add(学号)
    box3add(new JLabel(成绩))
    box3add(成绩)
    box4add(录入)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())
    JPanel messPanelnew JPanel()
    messPaneladd(boxH)
    setLayout(new BorderLayout())
    add(messPanelBorderLayoutCENTER)
    validate()
    }
    public void actionPerformed(ActionEvent c){
    Object objcgetSource()
    if(obj录入){
    if(课号getText()equals()||学号getText()equals()){
    JOptionPaneshowMessageDialog(this填写课号学号录入 )
    }
    else
    {
    Statement stmtnull
    ResultSet rsnullrs1nullrsCnullrsSnull
    String sqlsql1sqlSsqlC
    sqlCselect * from C where Cno'+课号getText()+'
    sqlSselect * from S where Sno'+学号getText()+'
    sql1select * from SC where Cno'+课号getText()+' and Sno'+学号getText()+'
    sqlinsert into SC values('+课号getText()+''+学号getText()+''+成绩getText()+')
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_R
    EAD_ONLY)
    rsCstmtexecuteQuery(sqlC)
    if(rsCnext()){
    rsSstmtexecuteQuery(sqlS)
    if(rsSnext()){
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){JOptionPaneshowMessageDialog(this该学生选该课程号法添加)}
    else{
    stmtexecuteUpdate(sql)
    JOptionPaneshowMessageDialog(this添加成功)
    }
    rs1close()
    }
    else{JOptionPaneshowMessageDialog(this该学生存法添加)}
    rsSclose()
    }
    else{JOptionPaneshowMessageDialog(this该课程存法添加)}
    rsCclose()
    stmtclose()
    }
    catch(SQLException e){
    Systemoutprint(SQL Exception occurMessage is+egetMessage())
    }
    }
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }




    Addstujaba:


    import javaawt*
    import javaxswing*
    import javasql*
    import javaawtevent*


    public class Addstu extends JPanel implements ActionListener{
    JTextField 学号姓名系
    JButton 录入

    public Addstu(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}

    学号new JTextField(12)
    姓名new JTextField(12)
    系new JTextField(12)
    录入new JButton(录入)
    录入addActionListener(this)

    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    box1add(new JLabel(学号*JLabelCENTER*))
    box1add(学号)
    box2add(new JLabel(姓名*JLabelCENTER*))
    box2add(姓名)
    box3add(new JLabel(系*JLabelCENTER*))
    box3add(系)
    box4add(录入)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())
    JPanel messPanelnew JPanel()
    messPaneladd(boxH)
    setLayout(new BorderLayout())
    add(messPanelBorderLayoutCENTER)
    validate()
    }
    public void actionPerformed(ActionEvent c){
    Object objcgetSource()
    if(obj录入){
    if(学号getText()equals()||姓名getText()equals()||系getText()equals()){
    JOptionPaneshowMessageDialog(this学生信息请填满录入 )
    }
    Statement stmtnull
    ResultSet rs1null
    String sqlsql1
    sql1select * from S where Sno'+学号getText()+'
    sqlinsert into S values('+学号getText()+''+姓名getText()+''+系getText()+')
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){JOptionPaneshowMessageDialog(this该学号存法添加)}
    else{
    stmtexecuteUpdate(sql)
    JOptionPaneshowMessageDialog(this添加成功)
    }
    rs1close()
    stmtclose()
    }
    catch(SQLException e){
    Systemoutprint(SQL Exception occurMessage is+egetMessage())
    }
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }

    }

    DelCjava

    import javaawt*
    import javaawtevent*
    import javasql*
    import javaxswing*
    public class DelC extends JPanel implements ActionListener{
    String savenull
    JTextField 课号1课号课名
    JButton 删查找

    public DelC(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}

    课号1new JTextField(12)
    课号new JTextField(12)
    课名new JTextField(12)
    删new JButton(删)
    查找new JButton(查找)

    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    box1add(new JLabel(课号JLabelCENTER))
    box1add(课号)
    box2add(new JLabel(课名JLabelCENTER))
    box2add(课名)
    box4add(删)
    box5add(new JLabel(课号JLabelCENTER))
    box5add(课号1)
    box5add(查找)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())

    删addActionListener(this)
    查找addActionListener(this)

    JPanel picPanelnew JPanel()
    JPanel messPanelnew JPanel()
    messPaneladd(box5)
    picPaneladd(boxH)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    validate()

    }
    public void actionPerformed(ActionEvent e){
    Object objegetSource()
    Statement stmtnull
    ResultSet rsnullrs1null
    String sqlnullsql1nullsqlSCnull
    if(obj查找){if(课号1getText()equals())JOptionPaneshowMessageDialog(this请填写查询课号 )
    else{
    sql1select * from C where Cno'+课号1getText()+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){课号setText(rs1getString(Cno)trim())
    课名setText(rs1getString(Cname)trim())
    save课号1getText()trim()
    }
    else{JOptionPaneshowMessageDialog(this没课号课程 )}
    stmtclose()
    rs1close()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }
    else{
    if(obj删){if(savenull)JOptionPaneshowMessageDialog(this没查找需修改课程 )
    else{sqldelete from C where Cno'+save+'
    sqlSCdelete from SC where Cno'+save+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    stmtexecuteUpdate(sql)
    stmtexecuteUpdate(sqlSC)
    savenull
    JOptionPaneshowMessageDialog(this删完成 )
    课号setText()
    课名setText()

    stmtclose()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }


    DelSCjava

    import javaawt*
    import javaawtevent*
    import javasql*
    import javaxswing*

    public class DelSC extends JPanel implements ActionListener{
    String saveCnull
    String saveSnull
    JTextField 课号1学号1学号课号成绩
    JButton 删查找

    public DelSC(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}

    学号1new JTextField(12)
    课号1new JTextField(12)
    课号new JTextField(12)
    学号new JTextField(12)
    成绩new JTextField(12)
    删new JButton(删)
    查找new JButton(查找)

    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    box1add(new JLabel(课号JLabelCENTER))
    box1add(课号)
    box2add(new JLabel(学号JLabelCENTER))
    box2add(学号)
    box3add(new JLabel(成绩JLabelCENTER))
    box3add(成绩)
    box4add(删)
    box5add(new JLabel(课号JLabelCENTER))
    box5add(课号1)
    box5add(new JLabel(学号JLabelCENTER))
    box5add(学号1)
    box5add(查找)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())

    删addActionListener(this)
    查找addActionListener(this)

    JPanel picPanelnew JPanel()
    JPanel messPanelnew JPanel()
    messPaneladd(box5)
    picPaneladd(boxH)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    validate()

    }
    public void actionPerformed(ActionEvent e){
    Object objegetSource()
    Statement stmtnull
    ResultSet rsnullrs1null
    String sqlnullsql1null

    if(obj查找){if(课号1getText()equals()||学号1getText()equals())JOptionPaneshowMessageDialog(this请填写完成查询信息 )
    else{

    sql1select * from SC where Cno'+课号1getText()+' and Sno'+学号1getText()+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){课号setText(rs1getString(Cno)trim())
    学号setText(rs1getString(Sno)trim())
    成绩setText(rs1getString(C)trim())
    saveC课号1getText()trim()
    saveS学号1getText()trim()
    }
    else{JOptionPaneshowMessageDialog(this没课号学生 )}
    stmtclose()
    rs1close()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }
    else{
    if(obj删){if(saveCnull||saveSnull)JOptionPaneshowMessageDialog(this没查找需修改学生课程 )
    else{sqldelete from SC where Cno'+saveC+' and Sno'+saveS+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    stmtexecuteUpdate(sql)
    saveCnull
    saveSnull
    JOptionPaneshowMessageDialog(this删完成 )
    课号setText()
    学号setText()
    成绩setText()
    stmtclose()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }


    Delstujava

    import javaawt*
    import javaawtevent*
    import javasql*
    import javaxswing*


    public class Delstu extends JPanel implements ActionListener{
    String savenull
    JTextField 学号1学号姓名系
    JButton 删查找

    public Delstu(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}

    学号1new JTextField(12)
    学号new JTextField(12)
    姓名new JTextField(12)
    系new JTextField(12)
    删new JButton(删)
    查找new JButton(查找)

    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    box1add(new JLabel(学号JLabelCENTER))
    box1add(学号)
    box2add(new JLabel(姓名JLabelCENTER))
    box2add(姓名)
    box3add(new JLabel(系JLabelCENTER))
    box3add(系)
    box4add(删)
    box5add(new JLabel(学号JLabelCENTER))
    box5add(学号1)
    box5add(查找)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())

    删addActionListener(this)
    查找addActionListener(this)

    JPanel picPanelnew JPanel()
    JPanel messPanelnew JPanel()
    messPaneladd(box5)
    picPaneladd(boxH)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    validate()
    }
    public void actionPerformed(ActionEvent e){
    Object objegetSource()
    Statement stmtnull
    ResultSet rsnullrs1null
    String sqlnullsql1nullsqlSCnull

    if(obj查找){if(学号1getText()equals())JOptionPaneshowMessageDialog(this请填写查询学号 )
    else{
    sql1select * from S where Sno'+学号1getText()+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){学号setText(rs1getString(Sno)trim())
    姓名setText(rs1getString(Sname)trim())
    系setText(rs1getString(Sx)trim())
    save学号1getText()trim()
    }
    else{JOptionPaneshowMessageDialog(this没学号学生 )}
    stmtclose()
    rs1close()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }
    else{
    if(obj删){if(savenull)JOptionPaneshowMessageDialog(this没查找需修改学生 )
    else{sqldelete from S where Sno'+save+'
    sqlSCdelete from SC where Sno'+save+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    stmtexecuteUpdate(sql)
    stmtexecuteUpdate(sqlSC)
    savenull
    JOptionPaneshowMessageDialog(this删完成 )
    学号setText()
    姓名setText()
    系setText()

    stmtclose()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }

    Menujava

    import javaawt*
    import javaawtevent*
    import javaxswing*

    public class Menu extends JFrame implements ActionListener{
    Addstu 增加学生界面
    Updatastu 修改学生界面
    Delstu 删学生界面
    AddC 增加课程界面
    DelC 删课程界面
    UpdateC 修改课程界面
    AddSC 增加选课界面
    DelSC 删选课界面
    UpdateSC 修改选课界面
    Selstu 学生查询界面
    JPanel pCenter
    CardLayout cardnull
    JLabel labelnull
    JMenuBar mbnew JMenuBar()菜单栏
    JMenu m1new JMenu(学生理)
    JMenuItem add1new JMenuItem(add1 )
    JMenuItem updata1new JMenuItem(updata1 )
    JMenuItem delete1new JMenuItem(delete1 )
    JMenu m2new JMenu(课程理)
    JMenuItem add2new JMenuItem(add2 )
    JMenuItem updata2new JMenuItem(updata2 )
    JMenuItem delete2new JMenuItem(delete2 )
    JMenu m3new JMenu(选课理)
    JMenuItem add3new JMenuItem(add3 )
    JMenuItem updata3new JMenuItem(updata3 )
    JMenuItem delete3new JMenuItem(delete3 )
    JMenu m4new JMenu(查询理)
    JMenuItem 学生查询new JMenuItem(查询信息 )
    JMenuItem m5new JMenuItem(系统退出)
    Font tnew Font (sanerifFontPLAIN12)
    public Menu (){
    thissetTitle(学生选课理系统)
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}
    组合菜单
    addMenu1()
    addMenu2()
    addMenu3()
    addMenu4()
    addJMenuBar()
    setJMenuBar(mb)

    labelnew JLabel(选课理系统JLabelCENTER)
    labelsetFont(new Font(宋体FontBOLD36))
    labelsetHorizontalTextPosition(SwingConstantsCENTER)
    labelsetForeground(Colorred)
    点击事件
    add1addActionListener(this)
    updata1addActionListener(this)
    delete1addActionListener(this)
    m5addActionListener(this)
    add2addActionListener(this)
    delete2addActionListener(this)
    updata2addActionListener(this)
    add3addActionListener(this)
    delete3addActionListener(this)
    updata3addActionListener(this)
    学生查询addActionListener(this)

    cardnew CardLayout()
    pCenternew JPanel()
    pCentersetLayout(card)

    增加学生界面new Addstu()
    修改学生界面new Updatastu()
    删学生界面new Delstu()
    增加课程界面new AddC()
    删课程界面new DelC()
    修改课程界面new UpdateC()
    增加选课界面new AddSC()
    删选课界面new DelSC()
    修改选课界面new UpdateSC()
    学生查询界面new Selstu()

    pCenteradd(欢迎界面label)
    pCenteradd(增加学生界面增加学生界面)
    pCenteradd(修改学生界面修改学生界面)
    pCenteradd(删学生界面删学生界面)
    pCenteradd(增加课程界面增加课程界面)
    pCenteradd(删课程界面删课程界面)
    pCenteradd(修改课程界面修改课程界面)
    pCenteradd(增加选课界面增加选课界面)
    pCenteradd(删选课界面删选课界面)
    pCenteradd(修改选课界面修改选课界面)
    pCenteradd(学生查询界面 学生查询界面)

    add(pCenterBorderLayoutCENTER)
    validate()
    setVisible(true)
    setBounds(400150600380)
    setDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
    addWindowListener(new WindowAdapter(){关闭程序时操作
    public void windowClosing(WindowEvent e){Systemexit(0)}
    })
    validate()
    }

    private void addJMenuBar() {
    mbadd(m1)mbadd(m2)mbadd(m3)mbadd(m4)mbadd(m5)
    }
    private void addMenu4() {
    m4add(学生查询)
    m4setFont(t)
    }
    private void addMenu3() {
    m3add(add3)
    m3add(updata3)
    m3add(delete3)
    m3setFont(t)
    }
    private void addMenu2() {菜单加入菜单栏中
    m2add(add2)
    m2add(updata2)
    m2add(delete2)
    m2setFont(t)
    }
    private void addMenu1() {
    m1add(add1)
    m1add(updata1)
    m1add(delete1)
    m1setFont(t)字体
    }

    public void actionPerformed(ActionEvent e){
    Object objegetSource()
    if(objm5){Systemexit(0)}
    else{if(objadd1){
    cardshow(pCenter增加学生界面)
    }
    else{if(objupdata1){
    cardshow(pCenter修改学生界面)
    }
    else{if(objdelete1){
    cardshow(pCenter 删学生界面)
    }
    else{if(objadd2){
    cardshow(pCenter 增加课程界面)
    }
    else{if(objdelete2){
    cardshow(pCenter 删课程界面)
    }
    else{if(objupdata2){
    cardshow(pCenter 修改课程界面)
    }
    else{if(objadd3){
    cardshow(pCenter 增加选课界面)
    }
    else{if(objdelete3){
    cardshow(pCenter 删选课界面)
    }
    else{if(objupdata3){
    cardshow(pCenter 修改选课界面)
    }
    else{if(obj学生查询){
    cardshow(pCenter 学生查询界面)
    }}
    }}}}}}}}}}
    public static void main(String[] args) {
    new Menu()
    }



    SelCjava

    import javasql*
    import javaawt*
    import javaawtevent*
    import javaxswing*

    import javautil*

    public class SelC extends JFrame {
    Vector rowData columnNames
    Statement stmtnull
    String sqlnull
    JTable jt null
    JScrollPane jsp null
    PreparedStatement psnull
    ResultSet rsnull
    public SelC(String sql1){
    columnNames new Vector()
    设置列名
    columnNamesadd(课号)
    columnNamesadd(课名)

    rowDatanew Vector()
    sqlsql1
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rsstmtexecuteQuery(sql)

    while(rsnext()){
    Vector hang new Vector()
    hangadd(rsgetString(Cno))Systemoutprint(rsgetString(Cno))
    hangadd(rsgetString(Cname))Systemoutprint(rsgetString(Cname))
    rowDataadd(hang)}
    jtnew JTable(rowDatacolumnNames)
    jspnew JScrollPane(jt)
    thisadd(jsp)
    thissetSize(400300)
    thissetVisible(true)
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }


    SelSCjava


    import javasql*
    import javaxswing*

    import javautil*

    public class SelSC extends JFrame {
    Vector rowData columnNames
    Statement stmtnull
    String sqlnull
    JTable jt null
    JScrollPane jsp null
    PreparedStatement psnull
    ResultSet rsnull
    public SelSC(String sql1){
    columnNames new Vector()
    设置列名
    columnNamesadd(课号)
    columnNamesadd(课名)
    columnNamesadd(学号)
    columnNamesadd(姓名)
    columnNamesadd(成绩)

    rowDatanew Vector()
    sqlsql1
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rsstmtexecuteQuery(sql)

    while(rsnext()){
    Vector hang new Vector()
    hangadd(rsgetString(Cno))Systemoutprint(rsgetString(Cno))
    hangadd(rsgetString(Cname))Systemoutprint(rsgetString(Cname))
    hangadd(rsgetString(Sno))Systemoutprint(rsgetString(Sno))
    hangadd(rsgetString(Sname))Systemoutprint(rsgetString(Sname))
    hangadd(rsgetString(C))Systemoutprintln(rsgetString(C))
    rowDataadd(hang)}
    jtnew JTable(rowDatacolumnNames)
    jspnew JScrollPane(jt)
    thisadd(jsp)
    thissetSize(400300)
    thissetVisible(true)
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }


    Selstujava

    import javaawt*
    import javaawtevent*
    import javasql*
    import javaxswing*
    public class Selstu extends JPanel implements ActionListener{
    JTextField 学号姓名系
    JButton 查找
    JTextField 课号课名
    JButton 查找1
    JTextField 课号1学号1成绩
    JButton 查找2

    public Selstu (){
    学号new JTextField(12)
    姓名new JTextField(12)
    系new JTextField(12)
    课号new JTextField(12)
    课名new JTextField(12)
    课号1new JTextField(12)
    学号1new JTextField(12)
    成绩new JTextField(12)
    查找new JButton(查找学生信息)
    查找1new JButton(查找课程信息)
    查找2new JButton(查找选课信息)


    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    Box box6BoxcreateHorizontalBox()
    Box box7BoxcreateHorizontalBox()
    box1add(new JLabel(学号JLabelCENTER))
    box1add(学号)
    box1add(new JLabel(姓名JLabelCENTER))
    box1add(姓名)
    box1add(new JLabel(系JLabelCENTER))
    box1add(系)
    box2add(查找)

    box4add(new JLabel(课号JLabelCENTER))
    box4add(课号)
    box4add(new JLabel(课名JLabelCENTER))
    box4add(课名)
    box6add(查找1)

    box5add(new JLabel(课号JLabelCENTER))
    box5add(课号1)
    box5add(new JLabel(学号JLabelCENTER))
    box5add(学号1)
    box5add(new JLabel(成绩JLabelCENTER))
    box5add(成绩)
    box7add(查找2)

    Box boxH1BoxcreateVerticalBox()竖放box
    boxH1add(box1)
    boxH1add(box2)
    boxH1add(BoxcreateVerticalGlue())
    Box boxH2BoxcreateVerticalBox()竖放box
    boxH2add(box4)
    boxH2add(box6)
    boxH2add(BoxcreateVerticalGlue())
    Box boxH3BoxcreateVerticalBox()竖放box
    boxH3add(box5)
    boxH3add(box7)
    boxH3add(BoxcreateVerticalGlue())

    查找addActionListener(this)
    查找1addActionListener(this)
    查找2addActionListener(this)

    JPanel messPanelnew JPanel()
    JPanel picPanelnew JPanel()
    JPanel threePanelnew JPanel()
    messPaneladd(boxH1)
    picPaneladd(boxH2)
    threePaneladd(boxH3)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    JSplitPane splitV1new JSplitPane(JSplitPaneVERTICAL_SPLITsplitVthreePanel)分割
    add(splitV1BorderLayoutCENTER)
    validate()


    }

    public void actionPerformed(ActionEvent c){
    Object objcgetSource()
    Statement stmtnull
    ResultSet rsnull
    int row0
    int i0
    String sqlnull
    Students K
    SelC K1
    SelSC K2
    if(obj查找){
    if(学号getText()equals()&&姓名getText()equals()&&系getText()equals()){
    sqlselect * from S Systemoutprint(000)000
    }
    else{
    if(学号getText()equals()){
    if(姓名getText()equals()){
    sqlselect * from S where Sx like'+系getText()+'Systemoutprint(001)}
    else{if(系getText()equals()){sqlselect * from S where Sname like'+姓名getText()+'Systemoutprint(010)}
    else{sqlselect * from S where Sname like'+姓名getText()+'and Sx like'+系getText()+'Systemoutprint(011)}}}
    else{if(姓名getText()equals()){
    if(系getText()equals()){sqlselect * from S where Sno like'+学号getText()+'Systemoutprint(100)}
    else{sqlselect * from S where Sno like'+学号getText()+' and Sx like'+系getText()+'Systemoutprint(101)}}
    else{if(系getText()equals()){sqlselect * from S where Sno like'+学号getText()+' and Sname like'+姓名getText()+'Systemoutprint(110)}
    else{sqlselect * from S where Sno like'+学号getText()+' and Sname like'+姓名getText()+' and Sx like'+系getText()+'Systemoutprint(111)}}}
    }
    Knew Students(sql)
    }
    else{if(obj查找1){
    if(课号getText()equals()&&课名getText()equals()){
    sqlselect * from C Systemoutprint(00)00
    }
    else{
    if(课号getText()equals()){sqlselect * from C where Cname like'+课名getText()+'Systemoutprint(01)}
    else{if(系getText()equals()){sqlselect * from C where Cno like'+课号getText()+'Systemoutprint(10)}
    else{sqlselect * from C where Cno like'+课号getText()+' and Cname like'+姓名getText()+'Systemoutprint(11)}
    }
    }
    K1new SelC(sql)}
    else{if(obj查找2){
    if(课号1getText()equals()&&学号1getText()equals()&&成绩getText()equals()){
    sqlselect SCCnoCnameSCSnoSnameC from SCCS where CCnoSCCno and SSnoSCSnoSystemoutprint(000)000
    }
    else{
    if(课号1getText()equals()){
    if(学号1getText()equals()){
    sqlselect SCCnoCnameSCSnoSnameC from SCCS where C like'+成绩getText()+' and CCnoSCCno and SSnoSCSnoSystemoutprint(001)}
    else{if(成绩getText()equals()){sqlselect SCCnoCnameSCSnoSnameC from SCCS where SCSno like'+学号1getText()+' and CCnoSCCno and SSnoSCSnoSystemoutprint(010)}
    else{sqlselect SCCnoCnameSCSnoSnameC from SCCS where SCSno like'+学号1getText()+'and C like'+成绩getText()+' and CCnoSCCno and SSnoSCSnoSystemoutprint(011)}}}
    else{if(学号1getText()equals()){
    if(成绩getText()equals()){sqlselect SCCnoCnameSCSnoSnameC from SCCS where SCCno like'+课号1getText()+' and CCnoSCCno and SSnoSCSnoSystemoutprint(100)}
    else{sqlselect SCCnoCnameSCSnoSnameC from SCCS where SCCno like'+课号1getText()+' and C like'+成绩getText()+' and CCnoSCCno and SSnoSCSnoSystemoutprint(101)}}
    else{if(成绩getText()equals()){sqlselect SCCnoCnameSCSnoSnameC from SCCS where SCCno like'+课号1getText()+' and SCSno like'+学号1getText()+' and CCnoSCCno and SSnoSCSnoSystemoutprint(110)}
    else{sqlselect SCCnoCnameSCSnoSnameC from SCCS where SCCno like'+课号1getText()+' and SCSno like'+学号1getText()+' and C like'+成绩getText()+' and CCnoSCCno and SSnoSCSnoSystemoutprint(111)}}}
    }
    K2new SelSC(sql)
    }
    }
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }

    Studentjava

    import javasql*
    import javaxswing*
    import javautil*

    public class Students extends JFrame {
    Vector rowData columnNames
    Statement stmtnull

    String sqlnull
    JTable jt null
    JScrollPane jsp null
    PreparedStatement psnull
    ResultSet rsnull
    public Students(String sql1){
    columnNames new Vector()
    设置列名
    columnNamesadd(学号)
    columnNamesadd(姓名)
    columnNamesadd(性)

    rowDatanew Vector()
    sqlsql1
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rsstmtexecuteQuery(sql)

    while(rsnext()){
    Vector hang new Vector()
    hangadd(rsgetString(Sno))Systemoutprint(rsgetString(Sno))
    hangadd(rsgetString(Sname))Systemoutprint(rsgetString(Sname))
    hangadd(rsgetString(Sx))Systemoutprintln(rsgetString(Sx))
    rowDataadd(hang)}
    jtnew JTable(rowDatacolumnNames)
    jspnew JScrollPane(jt)
    thisadd(jsp)
    thissetSize(400300)
    thissetVisible(true)
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }


    Updatastujava

    import javaawt*
    import javaawtevent*
    import javasql*
    import javaxswing*

    public class Updatastu extends JPanel implements ActionListener{
    String savenull
    JTextField 学号1学号姓名系
    JButton 修改查找

    public Updatastu(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}

    学号1new JTextField(12)
    学号new JTextField(12)
    姓名new JTextField(12)
    系new JTextField(12)
    修改new JButton(修改)
    查找new JButton(查找)

    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    box1add(new JLabel(学号JLabelCENTER))
    box1add(学号)
    box2add(new JLabel(姓名JLabelCENTER))
    box2add(姓名)
    box3add(new JLabel(系JLabelCENTER))
    box3add(系)
    box4add(修改)
    box5add(new JLabel(学号JLabelCENTER))
    box5add(学号1)
    box5add(查找)

    修改addActionListener(this)
    查找addActionListener(this)

    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())
    JPanel picPanelnew JPanel()
    JPanel messPanelnew JPanel()
    messPaneladd(box5)
    picPaneladd(boxH)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    validate()
    }

    public void actionPerformed(ActionEvent e){
    Object objegetSource()
    Statement stmtnull
    ResultSet rsnullrs1null
    String sqlnullsql1nullsqlSC

    if(obj查找){if(学号1getText()equals())JOptionPaneshowMessageDialog(this请填写查询学号 )
    else{

    sql1select * from S where Sno'+学号1getText()+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){学号setText(rs1getString(Sno)trim())
    姓名setText(rs1getString(Sname)trim())
    系setText(rs1getString(Sx)trim())
    save学号1getText()
    }
    else{JOptionPaneshowMessageDialog(this没学号学生 )}
    stmtclose()
    rs1close()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }
    else{
    if(obj修改){if(savenull){JOptionPaneshowMessageDialog(this没查找需修改学生 )}
    else{
    if(学号getText()equals()||姓名getText()equals()||系getText()equals()){
    JOptionPaneshowMessageDialog(this学生信息填满修改 )
    }
    else{sqlupdate S set Sno'+学号getText()+'Sname'+姓名getText()+'Sx'+系getText()+'+where Sno'+save+'
    if(savetrim()equals(学号getText()trim())){
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    stmtexecuteUpdate(sql)
    savenull
    JOptionPaneshowMessageDialog(this修改完成 )
    学号setText()
    姓名setText()
    系setText()
    stmtclose()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    else{sql1select * from S where Sno'+学号getText()+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){ JOptionPaneshowMessageDialog(this已存学号学生 )
    }
    else{
    sqlSCupdate SC set Sno'+学号getText()+' where Sno'+save+'
    stmtexecuteUpdate(sql)
    stmtexecuteUpdate(sqlSC)
    savenull
    JOptionPaneshowMessageDialog(null修改完成 )
    学号setText()
    姓名setText()
    系setText()}
    stmtclose()
    rs1close()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }

    }

    }}}}
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }

    UpdateCjava

    import javaawt*
    import javaawtevent*
    import javasql*
    import javaxswing*

    public class UpdateC extends JPanel implements ActionListener{
    String savenull
    JTextField 课号1课号课名
    JButton 修改查找

    public UpdateC(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}

    课号1new JTextField(12)
    课号new JTextField(12)
    课名new JTextField(12)
    修改new JButton(修改)
    查找new JButton(查找)

    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    box1add(new JLabel(课号JLabelCENTER))
    box1add(课号)
    box2add(new JLabel(课名JLabelCENTER))
    box2add(课名)
    box3add(修改)
    box5add(new JLabel(课号JLabelCENTER))
    box5add(课号1)
    box5add(查找)

    修改addActionListener(this)
    查找addActionListener(this)

    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())
    JPanel picPanelnew JPanel()
    JPanel messPanelnew JPanel()
    messPaneladd(box5)
    picPaneladd(boxH)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    validate()
    }

    public void actionPerformed(ActionEvent e){
    Object objegetSource()
    Statement stmtnull
    ResultSet rsnullrs1null
    String sqlnullsql1nullsqlSCnull

    if(obj查找){if(课号1getText()equals())JOptionPaneshowMessageDialog(this请填写查询课号 )
    else{
    sql1select * from C where Cno'+课号1getText()+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){课号setText(rs1getString(Cno)trim())
    课名setText(rs1getString(Cname)trim())
    save课号1getText()
    }
    else{JOptionPaneshowMessageDialog(this没课号课程 )}
    stmtclose()
    rs1close()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }
    else{
    if(obj修改){if(savenull){JOptionPaneshowMessageDialog(this没查找需修改课程 )}
    else{
    if(课号getText()equals()||课名getText()equals()){
    JOptionPaneshowMessageDialog(this课程信息填满修改 )
    }
    else{sqlupdate C set Cno'+课号getText()+'Cname'+课名getText()+' where Cno'+save+'
    if(savetrim()equals(课号getText()trim())){
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    stmtexecuteUpdate(sql)
    savenull
    JOptionPaneshowMessageDialog(this修改完成 )
    课号setText()
    课名setText()
    stmtclose()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    else{sql1select * from C where Cno'+课号getText()+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){ JOptionPaneshowMessageDialog(this已存课号课程 )
    }
    else{sqlSCupdate SC set Sno'+课号getText()+' where Cno'+save+'
    stmtexecuteUpdate(sql)
    stmtexecuteUpdate(sqlSC)
    savenull
    JOptionPaneshowMessageDialog(null修改完成 )
    课号setText()
    课名setText()}
    stmtclose()
    rs1close()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }}}}
    }



    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }


    UpdateSCjava

    import javaawt*
    import javaawtevent*
    import javasql*

    import javaxswing*
    public class UpdateSC extends JPanel implements ActionListener{
    String saveCnull
    String saveSnull
    JTextField 课号1学号1学号课号成绩
    JButton 修改查找

    public UpdateSC(){
    try {UIManagersetLookAndFeel(UIManagergetSystemLookAndFeelClassName())}
    catch(Exception e){Systemerrprintln(设置外观 +e)}

    学号1new JTextField(12)
    课号1new JTextField(12)
    课号new JTextField(12)
    学号new JTextField(12)
    成绩new JTextField(12)
    修改new JButton(修改)
    查找new JButton(查找)

    Box box1BoxcreateHorizontalBox()横放box
    Box box2BoxcreateHorizontalBox()
    Box box3BoxcreateHorizontalBox()
    Box box4BoxcreateHorizontalBox()
    Box box5BoxcreateHorizontalBox()
    box1add(new JLabel(课号JLabelCENTER))
    box1add(课号)
    box2add(new JLabel(学号JLabelCENTER))
    box2add(学号)
    box3add(new JLabel(成绩JLabelCENTER))
    box3add(成绩)
    box4add(修改)
    box5add(new JLabel(课号JLabelCENTER))
    box5add(课号1)
    box5add(new JLabel(学号JLabelCENTER))
    box5add(学号1)
    box5add(查找)
    Box boxHBoxcreateVerticalBox()竖放box
    boxHadd(box1)
    boxHadd(box2)
    boxHadd(box3)
    boxHadd(box4)
    boxHadd(BoxcreateVerticalGlue())

    修改addActionListener(this)
    查找addActionListener(this)

    JPanel picPanelnew JPanel()
    JPanel messPanelnew JPanel()
    messPaneladd(box5)
    picPaneladd(boxH)
    setLayout(new BorderLayout())
    JSplitPane splitVnew JSplitPane(JSplitPaneVERTICAL_SPLITmessPanelpicPanel)分割
    add(splitVBorderLayoutCENTER)
    validate()
    }
    public void actionPerformed(ActionEvent e){
    Object objegetSource()
    Statement stmtnull
    ResultSet rsnullrs1nullrsCnullrsSnull
    String sqlsql1sqlSsqlC

    if(obj查找){if(课号1getText()equals()||学号1getText()equals())JOptionPaneshowMessageDialog(this请填写完成查询信息 )
    else{
    sql1select * from SC where Cno'+课号1getText()+' and Sno'+学号1getText()+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rs1stmtexecuteQuery(sql1)
    if(rs1next()){课号setText(rs1getString(Cno)trim())
    学号setText(rs1getString(Sno)trim())
    成绩setText(rs1getString(C)trim())
    saveC课号1getText()trim()
    saveS学号1getText()trim()
    }
    else{JOptionPaneshowMessageDialog(this没课号学生 )}
    stmtclose()
    rs1close()
    }catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }

    else{
    if(obj修改){if(saveCnull||saveSnull)JOptionPaneshowMessageDialog(this没查找需修改学生课程 )
    else{
    if(课号getText()equals()||学号getText()equals()){
    JOptionPaneshowMessageDialog(this课程信息填满修改 )
    }
    else{
    sqlCselect * from C where Cno'+课号getText()+'
    sqlSselect * from S where Sno'+学号getText()+'
    sql1select * from SC where Cno'+课号getText()+' and Sno'+学号getText()+'
    sqlupdate SC set Cno'+课号getText()+'Sno'+学号getText()+'C'+成绩getText()+' where Cno'+saveC+' and Sno'+saveS+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rsCstmtexecuteQuery(sqlC)
    if(rsCnext()){
    rsSstmtexecuteQuery(sqlS)
    if(rsSnext()){
    if(课号getText()trim()equals(saveC)&& 学号getText()trim()equals(saveS)){
    stmtexecuteUpdate(sql)
    JOptionPaneshowMessageDialog(this添加成功)
    saveCnull
    saveSnull
    }
    else{rs1stmtexecuteQuery(sql1)
    if(rs1next()){JOptionPaneshowMessageDialog(this学生课程号存法修改)}
    else{
    stmtexecuteUpdate(sql)
    JOptionPaneshowMessageDialog(this添加成功)
    saveCnull
    saveSnull
    }
    rs1close()
    }
    }
    else{JOptionPaneshowMessageDialog(this该学生存法修改)}
    rsSclose()
    }
    else{JOptionPaneshowMessageDialog(this该课程存法修改)}
    rsCclose()
    stmtclose()
    }
    catch(SQLException e1){
    Systemoutprint(SQL Exception occurMessage is+e1getMessage())
    }
    }
    }
    }
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull

    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }


    Userjava

    import javaawt*
    import javaawtevent*
    import javaxswing*
    import javasql*


    public class User extends JFrame{
    private JLabel usepassword
    private JTextField k1户名输入框
    private JPasswordField k2密码输入框
    private JButton b1b2

    登录窗口
    public User(JFrame f){
    super(系统登录)
    Container cgetContentPane()
    csetLayout(new FlowLayout())
    usenew JLabel(username)
    usesetFont(new Font(SerifFontPLAIN20))
    passwordnew JLabel(password)
    passwordsetFont(new Font(SerifFontPLAIN20))
    k1new JTextField(12)
    k2new JPasswordField(12)
    b1new JButton(登录)
    b2new JButton(退出)

    设置登录方法
    BHandler bnew BHandler()
    EXIT dnew EXIT()
    b1addActionListener(b)
    b2addActionListener(d)

    添加控件
    cadd(use)
    cadd(k1)
    cadd(password)
    cadd(k2)
    cadd(b1)
    cadd(b2)

    setBounds(600300250150)
    setVisible(true)
    setResizable(false)
    setDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
    }
    函数
    public static void main(String[] args) {
    User f1new User(new JFrame())
    }
    登录钮方法
    private class BHandler implements ActionListener{
    public void actionPerformed(ActionEvent event){
    if(k1getText()equals()||k2getText()equals()){
    JOptionPaneshowMessageDialog(Userthis户名密码空 )
    }
    else{
    Statement stmtnull
    ResultSet rsnull
    String sql
    sqlselect * from admin where username'+k1getText()+'
    try{
    Connection dbConn1CONN()
    stmt(Statement)dbConn1createStatement(ResultSetTYPE_SCROLL_INSENSITIVEResultSetCONCUR_READ_ONLY)
    rsstmtexecuteQuery(sql)
    if(rsnext()){
    String xmrsgetString(password)
    if(k2getText()equals(xmtrim())){JOptionPaneshowMessageDialog(Userthis登录成功)
    dispose()
    new Menu()理窗口
    }
    else{JOptionPaneshowMessageDialog(Userthis密码错误)}
    }
    else{JOptionPaneshowMessageDialog(Userthis户名错误)}
    rsclose()
    stmtclose()
    }
    catch(SQLException e){
    JOptionPaneshowMessageDialog(UserthisSQL Exception occurMessage is+egetMessage())
    }
    }
    }
    }
    退出方法结束
    private class EXIT implements ActionListener{
    public void actionPerformed(ActionEvent even){
    Systemexit(0)
    }
    }

    连接数库方法
    public static Connection CONN(){
    String driverName commicrosoftsqlserverjdbcSQLServerDriver 加载JDBC驱动
    String dbURL jdbcsqlserverlocalhost1433 DatabaseNamestudent 连接服务器数库test
    String userName sa 默认户名
    String userPwd huangjiwei 密码
    Connection dbConnnull
    try {
    ClassforName(driverName)
    dbConn DriverManagergetConnection(dbURL userName userPwd)
    Systemoutprintln(Connection Successful) 果连接成功 控制台输出Connection Successful
    } catch (Exception e) {
    eprintStackTrace()
    }
    return dbConn
    }
    }父类结束
    文档香网(httpswwwxiangdangnet)户传

    《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
    该内容是文档的文本内容,更好的格式请下载文档

    下载文档到电脑,查找使用更方便

    文档的实际排版效果,会与网站的显示效果略有不同!!

    需要 10 香币 [ 分享文档获得香币 ]

    下载文档

    相关文档

    Java与SQL数据库技术学生成绩管理系统课程设计

    《数据库系统原理》课程设计报告说明书学生信息管理系统学生姓名学 号所在专业所在班级指导教师提交时间 评阅情况成 绩目 录读书笔记 11. 学生信息管理系统概述 21.1 研...

    3年前   
    602    0

    MySql数据库课程设计(学生管理系统)

    XX大学数据库课程设计报告 系 院 应用科学学院 年 级 2013级 专 ...

    2年前   
    667    0

    学生选课系统《软件工程》课程设计

    详细版!目 录一、问题定义 51.1问题的定义 51.2 系统要解决的问题 5二、可行性研究 62.1 引言 62.1.1目的 62.1.2背景及功能 62.1.3 参考资料 62.2 可行...

    6个月前   
    327    0

    软件工程学生选课系统课程设计

    网上选课系统课程设计手册团队: 学校: 队长: 时间:2014目 录1. 项目概述 ………………………………………………………………………31.1开发背景 …………………………………………...

    3年前   
    620    0

    教师管理系统(数据库)课程设计

    数据库技术与应用(SQLServer2005)课 程 设 计题 目教师管理系统 组 员 班 级计科班学 院信息科学与工程学院指导教师 2012年 X...

    3年前   
    1291    0

    医院管理系统数据库课程设计

    医院管理系统数据库课程设计内容摘要数据库的设计是指对一个给定的应用环境,构造数据库模式,建立数据库及其应用系统,满足各种用户需求。作为信息资源开发、管理和服务的一种有效的手段,数据库技术的应用...

    1年前   
    422    0

    教务管理系统数据库课程设计报告

     《数据库原理》课程设计报告课程名称: 《数据库原理》课程设计 设计题目: 《教务管理系统》 指导教师: ...

    1年前   
    259    0

    数据库课程设计超市管理系统

    数 据 库 课 程 设 计 说 明 书设计题目: 超市管理系统 专 业: 信息与计算科学 班级: 小组成员:学号: ...

    2年前   
    488    0

    学生选课系统DFD图

    2.2.2 顶层DFD图根据分析得到的系统功能要求,画出学生选修课管理系统的分层DFD图。首先画出顶层的DFD图如图2-2所示。顶层确定了系统的范围,其外部实体为管理员、教师和学生。选课信息成...

    2年前   
    489    0

    uml课程设计网上选课系统

     UML课程设计学 院 信息学院 班 级 10级计本班 专 业 计算机科学与技术 课 题 网上选课...

    1年前   
    586    0

    基于java的学生信息管理系统

    科技带动计算机行业不断地发展,计算机行业的发展也给每个行业带来了巨大的收益,使其工作效率得到提高,同时方便了人们的生活。本系统使用SSM框架,主要采用自顶向下的相关研究的方法。

    3年前   
    780    0

    学生成绩管理系统数据库课程设计

     数据库课程设计报告题目: 学生成绩管理系统数据库设计 ...

    1年前   
    312    0

    软件工程专业课程设计——学生选课系统设计

     学生选课系统实验报告 项目名称:学生选课系统 姓名:学号:班级:指导老师:一. 课程设计的目的与要求通过软件开...

    2年前   
    547    0

    图书管理系统数据库设计数据库应用系统开发课程设计

    信息工程学院《数据库应用系统开发》课程设计论文题 目:图书管理系统数据库设计学 号:专业班级:信管级(X)班姓 名:魏 金 风指导老师:完成日期:2007摘 要在计算机日益普及...

    2年前   
    427    0

    人力资源管理系统数据库设计《数据库系统原理》课程设计报告

    《数据库系统原理》课程设计报告项目名称:人力资源管理系统数据库设计专 业: 计算机科学与技术 年 级: 姓 ...

    1年前   
    401    0

    基于CS框架的学生选课系统

     ...

    5年前   
    1262    0

    Java课程设计-教职工档案管理系统

    职工档案管理系统一.引言 1.1工程背景和目标 职工档案管理系统主要是对在校教师的个人根本信息以及教学信息进行管理,对教职工提供查询简介信息、教学信息功能;对管理员用户提供查询...

    2周前   
    76    0

    教学管理系统数据库课程设计报告

    《数据库原理与应用》课程设计课程名称 设计题目 专业班级 ...

    1年前   
    242    0

    数据库课程设计薪资管理系统

    《数据库类课程设计》系统开发报告学 号:   ********* 姓 名: ****** 题 目...

    6个月前   
    178    0

    物业管理系统数据库课程设计报告完整版

    设计题目:物业管理系统学 院:信息科学与工程学院专 业:计算机科学与技术班 级:计信学 号:学生姓名:指导教师:2014 年 X月 X 日目 录1 系统背景 32...

    3年前   
    685    0

    文档贡献者

    文***品

    贡献于2019-06-22

    下载需要 10 香币 [香币充值 ]
    亲,您也可以通过 分享原创文档 来获得香币奖励!
    下载文档

    该用户的其他文档