jsp 问题,怎么连接数据库

来源:百度知道 编辑:UC知道 时间:2024/06/22 22:00:53
菜鸟问下,比如我做了个html的登录页面只有name,password和email,在第二个页面用jsp接收html传来的值后,还要怎么做才能提交到数据库呢?
请大家给个代码参考参考,谢谢了!
用mysql数据库说说

一般书上都会有的把 这个知识点

public class UserOption {
public UserOption() {
}

public String getPassword(String username) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String passwordFromdb = null;
try {
conn = ConnectDB.getConnction();
stmt = conn.createStatement();
String sql="select pass from users where name='" +username + "'";
//System.out.println(sql);
rs = stmt.executeQuery(sql);
while (rs.next()) {
passwordFromdb = rs.getString("pass");
}
} catch (Exception e) {
System.out.println(e.getMessage());
}

finally {

ConnectDB.closeResultSet(rs);
ConnectDB.closeStatement(stmt);
ConnectDB.closeConnection(conn);
}

return passwordFromdb;
}
}

应该是把它该成插入就行了吧 你参考一下 这个是判断用户的

兄弟一般书上都会讲到 这个很基础的 我以前也搞过 基础的问题尽量尝试自己解决 这样比较好 学