import java.sql.DriverManager
import java.sql.ResultSet
import java.sql.Statementpublic class ConnectionFactory {
private Connection conn=null
private Statement stmt=null
private ResultSet rs=null
public ConnectionFactory() {
super()
你用的是if,没有执行循环,应该用 while
public List<Msg> getAllMsgList() {List<Msg> msgList = new ArrayList<Msg>()
DBConnection db = new DBConnection()
Connection conn = db.getConn()
String sql = "select * from msg"
try {
Statement pstmt = conn.createStatement()
ResultSet rs = pstmt.executeQuery(sql)
while (rs.next()) {
int id = rs.getInt(1)
String content = rs.getString(2)
String author = rs.getString(3)
String publishiTime = rs.getString(4)
Msg msg = new Msg(id, content, author, publishiTime)
msgList.add(msg)
}
rs.close()
pstmt.close()
conn.close()
} catch (SQLException e) {
e.printStackTrace()
}
return msgList
1.调差问卷只有只有一页,比如姓名 等2.然后把这些信息保存到mysql数据库中
3.需要用到ssm框架吗?
4.可以从什么地方找类似的代码呀?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)