java mysql项目案例_Java学生管理系统项目案例

标签:

分代码如下

package com.student.util;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

public class DbUtil {

private String dbUrl="jdbc:mysql://localhost:3306/db_student";

private String user="root";

private String password="123456";

private String jdbcName="com.mysql.jdbc.Driver";

public Connection getCon() throws Exception{

Class.forName(jdbcName);

Connection con=DriverManager.getConnection(dbUrl, user, password);

return con;

}

public void close(Connection con)throws Exception{

if(con!=null){

con.close();

}

}

public static void main(String[] args){

Connection con=null;

try {

con = new DbUtil().getCon();

System.out.println(con);

} catch (Exception e) {

e.printStackTrace();

}finally{

if(con!=null){

try {

con.close();

} catch (SQLException e) {

e.printStackTrace();

}

}

}

}

}

package com.student.model;

public class Student {

private int id;

private String studentnumber;

private String name;

private String birthday;

private String nativeplace;

private int classid;

private String studentremark;

public Student() {

super();

}

public Student(String studentnumber, String name, String birthday,

String nativeplace, int classid, String studentremark) {

super();

this.studentnumber = studentnumber;

this.name = name;

this.birthday = birthday;

this.nativeplace = nativeplace;

this.classid = classid;

this.studentremark = studentremark;

}

public Student(int id, String studentnumber, String name, String birthday,

String nativeplace, int classid, String studentremark) {

super();

this.id = id;

this.studentnumber = studentnumber;

this.name = name;

this.birthday = birthday;

this.nativeplace = nativeplace;

this.classid = classid;

this.studentremark = studentremark;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getStudentnumber() {

return studentnumber;

}

public void setStudentnumber(String studentnumber) {

this.studentnumber = studentnumber;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getBirthday() {

return birthday;

}

public void setBirthday(String birthday) {

this.birthday = birthday;

}

public String getNativeplace() {

return nativeplace;

}

public void setNativeplace(String nativeplace) {

this.nativeplace = nativeplace;

}

public int getClassid() {

return classid;

}

public void setClassid(int classid) {

this.classid = classid;

}

public String getStudentremark() {

return studentremark;

}

public void setStudentremark(String studentremark) {

this.studentremark = studentremark;

}

}

效果图

b26902eb677e2091535455833b10599c.png 

401008430f5a5f6bca16a27f2e7d6828.png 

详细说明:http://java.662p.com/thread-3620-1-1.html

标签:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值