javaweb1

<%@ page language="java" import="java.sql.*" import="java.util.*" pageEncoding="UTF-8"%> Insert <% String driverName="com.mysql.jdbc.Driver"; String dbName="MyLogin"; String userName="root"; String userPwd="5201314"; String url1="jdbc:mysql://localhost:3306/MyLogin"; String url2="?user=root&password=5201314"; String url3="&useUnicode=true&characterEncoding=UTF-8"; String url=url1+url2+url3; Class.forName(driverName); Connection conn=DriverManager.getConnection(url); String ss="Insert into checklog(id,password)values(?,?)"; PreparedStatement pstmt=conn.prepareStatement(ss); request.setCharacterEncoding("UTF-8"); int id=Integer.parseInt(request.getParameter("ZName")); int password=Integer.parseInt(request.getParameter("ZPassword")); pstmt.setInt(1,id); pstmt.setInt(2,password); int n=pstmt.executeUpdate(); if(n==1){%>注册成功!

返回登录界面!!<%}else{%>数据插入失败!
<%} if(pstmt!=null){pstmt.close();} if(conn!=null){conn.close();} %>

posted on 2017-10-24 21:27  哈哈呵  阅读(118)  评论(0)    收藏  举报

导航