javaweb项目中,这些代码大致是什么意思,我看不懂
这些代码大致是什么意思,我看不懂,从百度上搜也没有找到合适的解释,还希望知道的大神不吝赐教!!!急急急谢谢publicList<ValueOne>getAllValue(...
这些代码大致是什么意思,我看不懂,从百度上搜也没有找到合适的解释 ,还希望知道的大神不吝赐教!!!急急急 谢谢
public List<ValueOne> getAllValue() {
List<ValueOne> list = new ArrayList<ValueOne>();
StringBuilder sb = new StringBuilder();
//StringBuilder是一个类,可以用来处理字符串,最简单的用法:StringBuilder sb=new StringBuilder();
//sb.Append("123");
//sb.Append("456");
//string str=sb.ToString();
//最后得到的str字符串的值就是"123456",这种用法要比直接字符串相加效率高,
sb.append("select id,name,describe from valueOne");
try {
conn = getConn();
pstmt = conn.prepareStatement(sb.toString());
rs = pstmt.executeQuery();
while (rs.next()) {
int did = rs.getInt("id");
String name = rs.getString("name");
String describe = rs.getString("describe");
ValueOne drug = new ValueOne(did, name,describe);
list.add(drug);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
closeAll(rs, pstmt, conn);
}
return list;
}
} 展开
public List<ValueOne> getAllValue() {
List<ValueOne> list = new ArrayList<ValueOne>();
StringBuilder sb = new StringBuilder();
//StringBuilder是一个类,可以用来处理字符串,最简单的用法:StringBuilder sb=new StringBuilder();
//sb.Append("123");
//sb.Append("456");
//string str=sb.ToString();
//最后得到的str字符串的值就是"123456",这种用法要比直接字符串相加效率高,
sb.append("select id,name,describe from valueOne");
try {
conn = getConn();
pstmt = conn.prepareStatement(sb.toString());
rs = pstmt.executeQuery();
while (rs.next()) {
int did = rs.getInt("id");
String name = rs.getString("name");
String describe = rs.getString("describe");
ValueOne drug = new ValueOne(did, name,describe);
list.add(drug);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
closeAll(rs, pstmt, conn);
}
return list;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询