团队第一阶段冲刺2总结
作者:互联网
团队第一阶段冲刺二:
编写了bean和jdbc
Jdbc.properites
username=root
password=041765rsh
url=jdbc:mysql://localhost:3306/supercook
driverClassName=com.mysql.jdbc.Driver
initialSize=5
maxActive=10
bean
food
package com.supercook.bean;
public class Food {
private int id;
private String foodname;
private double price;
private String kind;
private String position;
public Food() {
}
public Food(int id, String foodname, double price, String kind, String position) {
this.id = id;
this.foodname = foodname;
this.price = price;
this.kind = kind;
this.position = position;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFoodname() {
return foodname;
}
public void setFoodname(String foodname) {
this.foodname = foodname;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
@Override
public String toString() {
return "Food{" +
"id=" + id +
", foodname='" + foodname + '\'' +
", price=" + price +
", kind='" + kind + '\'' +
", position='" + position + '\'' +
'}';
}
}
Food2
package com.supercook.bean;
public class Food2 {
private int WId;
private String WPosition;
private double price;
private String WName;
private int id;
private String kind;
private String foodname;
private String imgPath = "img/2.jpg";
public Food2(int wId, String wPosition, double price, String wName, int id, String kind, String foodname, int score) {
WId = wId;
WPosition = wPosition;
this.price = price;
WName = wName;
this.id = id;
this.kind = kind;
this.foodname = foodname;
}
public int getWId() {
return WId;
}
public void setWId(int wId) {
WId = wId;
}
public String getWPosition() {
return WPosition;
}
public void setWPosition(String wPosition) {
WPosition = wPosition;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getWName() {
return WName;
}
public void setWName(String wName) {
WName = wName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public String getFoodname() {
return foodname;
}
public void setFoodname(String foodname) {
this.foodname = foodname;
}
public String getImgPath() {
return imgPath;
}
public void setImgPath(String imgPath) {
this.imgPath = imgPath;
}
public Food2(int wId,String wPosition,double price,String wName,int id,String kind,String foodname,String imgPath) {
WId = wId;
WPosition = wPosition;
this.price = price;
WName = wName;
this.id = id;
this.kind = kind;
this.foodname = foodname;
if(imgPath != null && !"".equals(imgPath)){
this.imgPath = imgPath;
}
}
@Override
public String toString() {
return "Food2{" +
"WId=" + WId +
", WPosition='" + WPosition + '\'' +
", price=" + price +
", WName='" + WName + '\'' +
", id=" + id +
", kind='" + kind + '\'' +
", foodname='" + foodname + '\'' +
", imgPath='" + imgPath + '\'' +
'}';
}
}
User
package com.supercook.bean;
public class User {
private String username;
private String password;
private String number;
private String email;
private String sex;
private String age;
private String weight;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getWeight() {
return weight;
}
public void setWeight(String weight) {
this.weight = weight;
}
public User(String username, String password, String number, String email, String sex, String age, String weight) {
this.username = username;
this.password = password;
this.number = number;
this.email = email;
this.sex = sex;
this.age = age;
this.weight = weight;
}
}
Window
package com.supercook.bean;
public class Windows {
private int WId;
private String WPosition;
private String WName;
private String src;
private int score;
public Windows(int WId, String WPosition, String WName, String src, int score) {
this.WId = WId;
this.WPosition = WPosition;
this.WName = WName;
this.src = src;
this.score = score;
}
public Windows() {
}
public int getWId() {
return WId;
}
public void setWId(int WId) {
this.WId = WId;
}
public String getWPosition() {
return WPosition;
}
public void setWPosition(String WPosition) {
this.WPosition = WPosition;
}
public String getWName() {
return WName;
}
public void setWName(String WName) {
this.WName = WName;
}
public String getSrc() {
return src;
}
public void setSrc(String src) {
this.src = src;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
@Override
public String toString() {
return "Windows{" +
"WId=" + WId +
", WPosition='" + WPosition + '\'' +
", WName='" + WName + '\'' +
", src='" + src + '\'' +
", score=" + score +
'}';
}
}
Jdbc
package com.supercook.dButils;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
public class JdbcUtils {
private static DruidDataSource dataSource;
static {
try {
Properties properties = new Properties();
//读取Properties属性配置文件
InputStream inputStream = JdbcUtils.class.getClassLoader().getResourceAsStream("jdbc.properties");
//从流中加载数据
properties.load(inputStream);
//创建数据库连接池
dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取数据库连接池中的连接
* @return 如果为null,说明获取连接失败
* */
public static Connection getConnection(){
Connection conn = null;
try {
conn = dataSource.getConnection();
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
public static void close(Connection conn){
if(conn != null){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
标签:return,String,void,冲刺,foodname,private,团队,public,第一阶段 来源: https://www.cnblogs.com/20203923rensaihang/p/16373334.html