今日进行了增删改查的继续学习,熟悉之前的代码书写。
case "add": String name=request.getParameter("name"); String password=request.getParameter("password"); Student s=new Student(name,password); d.add(s); break;
public void add(Student s) { Connection connn=null; PreparedStatement preparedStatement=null; try { connn= Tool.getConnection(); String sql="insert into login (name,password) values (?,?)"; preparedStatement=connn.prepareStatement(sql); preparedStatement.setString(1,s.getName()); preparedStatement.setString(2,s.getPassword()); preparedStatement.executeUpdate(); } catch(SQLException e) { e.printStackTrace(); } finally { Tool.release(connn,preparedStatement,null); } }
标签:总结,preparedStatement,connn,每日,null,String,5.24,password,name From: https://www.cnblogs.com/syhxx/p/17429763.html