sql
来源:互联网 发布:程序员刚入职 编辑:程序博客网 时间:2024/06/06 06:32
sql public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
AddUserForm addUserForm = (AddUserForm) form;
String password = addUserForm.getPassword();
String username = addUserForm.getUsername();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:mysql://192.168.2.220:3306/test", "test", "test");
Statement stmt = conn.createStatement();
String sql = "select password from usertable where username='"
+ username + "'";
ResultSet rs = stmt.executeQuery(sql);
if (rs.next() != false) {
rs.close();
stmt.close();
conn.close();
System.out.println("user /"" + username
+ "/" is already in using..");
return (mapping.findForward("addfail"));
} else if (rs.next() == false) {
String insertsql = "insert into usertable(username,password) values('"
+ username + "'," + "'" + password + "')";
stmt.execute(insertsql);
rs.close();
stmt.close();
conn.close();
System.out.println("user /"" + username
+ "/" is added ok.....");
return (mapping.findForward("success"));
}
/*
* javax.sql.DataSource ds =
* getDataSource(servletRequest,"dataSource");
*
* Connection conn = ds.getConnection(); Statement
* stmt=conn.createStatement();
*
* String sql= "select password from user where username ='"
* +loginForm.getUsername()+"'"; ResultSet
* rs=stmt.executeQuery(sql);
*
*/
} catch (Throwable e) {
e.printStackTrace();
}
throw new java.lang.UnsupportedOperationException(
"Method $execute() not yet implemented.");
}
}
- SQL
- SQL
- SQL
- sql
- sql
- SQL
- sql
- SQL (-)
- sql
- SQL
- SQL
- SQL
- sql
- sql
- sql
- sql
- SQL
- sql
- SQL语言快速入门之一
- sql 数据库。。。
- SQL真实谎言
- test if a string is an integer?
- sql
- sql
- Oracle自治事务的介绍
- Linux下配置网卡信息
- mysql分页limit优化
- Hibernate之演示单向导航(一对多关联,利用联结表,以map为例)
- opc与ovoacomm进程异常情况
- STL学习(1)——基础
- 启动“上帝模式”非常简单
- ATL---Collection & Enumerater(1)