📄 dealmaterial.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -