dealmaterial.java
来自「简单的餐厅管理系统」· Java 代码 · 共 71 行
JAVA
71 行
package util;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import beans.Material;
import beans.User;
public class DealMaterial {
private Vector materials = new Vector();
public String getMaterial() {
BaseSQL b = new BaseSQL();
ResultSet rs = null;
try {
b.connect("eatery", "root", "123456");
rs = b.statement.executeQuery("select * from material");
while(rs.next()){
Material material = new Material();
material.setMaterialID(rs.getString("materialID"));
material.setName(rs.getString("materialName"));
// waiter.setUserName(rs.getString("userName"));
// waiter.setRealName(rs.getString("realName"));
//this.password = rs.getString("password");
// waiter.setType(rs.getInt("type"));
materials.add(material);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "连接数据库失败";
}catch(Exception e){
return "连接数据库失败";
}
finally{
try {
if(rs != null){
rs.close();
}
b.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}
public boolean hasMore(int i){
if(materials.size()>i){
return true;
}
return false;
}
public Vector getVector(){
return materials;
}
public Material getMaterial(int i){
Material use = (Material)materials.get(i);
return use;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?