之前写的有关Eclipse2020-06 IDE配置开发JavaWeb动态网页的博客:
eclipse2020-06中找不到Server(图文-tomcat-jsp)
eclipse2020-06配置tomcat(图文)
eclipse2020-06配置Dynamic Web Project创建web项目(图文)
eclipse2020-06新建JSP将编码修改成UTF-8(图文)
eclipse2020-06启动tomcat及修改发布项目名(图文)
eclipse2020-06快速生成seter和geter(图解)
eclipse2020-06创建Servlet(图解)
eclipse2020-06创建web.xml
eclipse2020-06创建属于自己的JSP模板(图文)
eclipse 2020 打开别人的代码中文乱码怎么办(图解教程)
eclipse2020-06找回一不小心删掉的java文件
创建JDBC模板
创建数据库查找模板
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = this.getConn();
// String sql = "select * from users where user_username=? and user_password=?";
ps = conn.prepareStatement(sql);
ps.setString(1, "");
ps.setString(2, "");
rs = ps.executeQuery();
// User user = null;
while (rs.next()) {
// user = new User();
// user.setId(rs.getInt(1));
// user.setUsername(rs.getString(2));
// user.setPassword(rs.getString(3));
}
return user;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
this.closeAll(rs, ps, conn);
}
创建数据库增删改模板
Connection conn = null;
PreparedStatement ps = null;
try {
conn = this.getConn();
// String sql = "update user set password=? , username=? where id=?";
ps = conn.prepareStatement(sql);
ps.setString(1, "");
ps.setString(2, "");
ps.setInt(3, 1);
int n = ps.executeUpdate();
return n;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
this.closeAll(rs, ps, conn);
}
关注我,带你一起写bug
warning :版权所有,转载请注明
有问题的小伙伴请在下方留言,喜欢就点个赞吧