JDBC商品管理系統(tǒng)(有登錄注冊(cè)功能改進(jìn)版)含個(gè)人注釋和查看建好表代碼的方法(二)

在所有SQL語句的編譯器中查看建好表代碼的方法:






.java2

package JDBC;
public class shangpin {
private int sp_ID;
private String sp_Jieshao;
private String sp_Name;
private double sp_Price;
private sp_Type sp_TypeID;
public shangpin() {
}
public shangpin(int sp_ID, String sp_Name, double sp_Price,
sp_Type sp_TypeID, String sp_Jieshao) {
this.sp_ID = sp_ID;
this.sp_Name = sp_Name;
this.sp_Price = sp_Price;
this.sp_TypeID = sp_TypeID;
this.sp_Jieshao = sp_Jieshao;
}
public int getSp_ID() {
return sp_ID;
}
public String getSp_Jieshao() {
return sp_Jieshao;
}
public String getSp_Name() {
return sp_Name;
}
public double getSp_Price() {
return sp_Price;
}
public sp_Type getSp_TypeID() {
return sp_TypeID;
}
public void setSp_ID(int sp_ID) {
this.sp_ID = sp_ID;
}
public void setSp_Jieshao(String sp_Jieshao) {
this.sp_Jieshao = sp_Jieshao;
}
public void setSp_Name(String sp_Name) {
this.sp_Name = sp_Name;
}
public void setSp_Price(double sp_Price) {
this.sp_Price = sp_Price;
}
public void setSp_TypeID(sp_Type sp_TypeID) {
this.sp_TypeID = sp_TypeID;
}
@Override
public String toString() {
return "shangpin [sp_ID=" + sp_ID + ", sp_Name=" + sp_Name
+ ", sp_Price=" + sp_Price + ", sp_TypeID=" + sp_TypeID
+ ", sp_Jieshao=" + sp_Jieshao + "]";
}
}

.java3


package JDBC;
public class sp_Type {
private int sp_TypeID;
private String sp_TypeName;
public sp_Type() {
}
public sp_Type(int sp_TypeID, String sp_TypeName) {
this.sp_TypeID = sp_TypeID;
this.sp_TypeName = sp_TypeName;
}
public int getSp_TypeID() {
return sp_TypeID;
}
public String getSp_TypeName() {
return sp_TypeName;
}
public void setSp_TypeID(int sp_TypeID) {
this.sp_TypeID = sp_TypeID;
}
public void setSp_TypeName(String sp_TypeName) {
this.sp_TypeName = sp_TypeName;
}
@Override
public String toString() {
return "sp_Type [sp_TypeID=" + sp_TypeID + ", sp_TypeName="
+ sp_TypeName + "]";
}
}

.java4

package JDBC;
public class yonghu {
private String yh_Address;// yh_Address代表用戶地址
private int yh_Age;// 代表用戶年齡
private int yh_ID;// 代表用戶編號(hào)
private String yh_Jieshao;// 代表用戶 個(gè)人介紹
private String yh_Name;// 代表用戶 真實(shí)姓名
private String yh_Phone;// 代表用戶 手機(jī)號(hào)
private String yh_Pwd;// 代表用戶 登錄密碼
private String yh_Sex;// 代表用戶 性別
private String yh_Uname;// 代表用戶登錄名
public String getYh_Address() {
return yh_Address;
}
public int getYh_Age() {
return yh_Age;
}
public int getYh_ID() {
return yh_ID;
}
public String getYh_Jieshao() {
return yh_Jieshao;
}
public String getYh_Name() {
return yh_Name;
}
public String getYh_Phone() {
return yh_Phone;
}
public String getYh_Pwd() {
return yh_Pwd;
}
public String getYh_Sex() {
return yh_Sex;
}
public String getYh_Uname() {
return yh_Uname;
}
public void setYh_Address(String yh_Address) {
this.yh_Address = yh_Address;
}
public void setYh_Age(int yh_Age) {
this.yh_Age = yh_Age;
}
public void setYh_ID(int yh_ID) {
this.yh_ID = yh_ID;
}
public void setYh_Jieshao(String yh_Jieshao) {
this.yh_Jieshao = yh_Jieshao;
}
public void setyh_Name(String string) {
}
public void setYh_Name(String yh_Name) {
this.yh_Name = yh_Name;
}
public void setYh_Phone(String yh_Phone) {
this.yh_Phone = yh_Phone;
}
public void setYh_Pwd(String yh_Pwd) {
this.yh_Pwd = yh_Pwd;
}
public void setYh_Sex(String yh_Sex) {
this.yh_Sex = yh_Sex;
}
public void setYh_Uname(String yh_Uname) {
this.yh_Uname = yh_Uname;
}
@Override
public String toString() {
return "yonghu [yh_ID=" + yh_ID + ", yh_Uname=" + yh_Uname
+ ", yh_Pwd=" + yh_Pwd + ", yh_Name=" + yh_Name + ", yh_Age="
+ yh_Age + ", yh_Sex=" + yh_Sex + ", yh_Phone=" + yh_Phone
+ ", yh_Address=" + yh_Address + ", yh_Jieshao=" + yh_Jieshao
+ "]";
}
}

.java5

package JDBC;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class diaoyongSQL {
private static Connection con = null;
private static ResultSet res = null;
private static Statement sta = null;
static {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static Connection getCon() {
if (con == null) {
try {
con = DriverManager.getConnection(
"jdbc:sqlserver://DESKTOP-49FTFSP;"
+ "databaseName=yonghu", "sa", "1234abcd");
} catch (SQLException e) {
e.printStackTrace();
}
}
return con;
}
public static ResultSet Select(String sql) {
con = getCon();
try {
sta = con.createStatement();
res = sta.executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return res;
}
public static boolean ZSG(String sql) {
boolean b = false;
con = getCon();
try {
sta = con.createStatement();
int num = sta.executeUpdate(sql);
if (num > 0) {
b = true;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return b;
}
}
