五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

servlet

2023-02-28 21:03 作者:靈咚  | 我要投稿

package demo;

import java.sql.*;


import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;




public class JDBC {


public Connection connect() throws ClassNotFoundException, SQLException{

? ? Connection conn=null;?

? ? Class.forName("com.mysql.jdbc.Driver");

? ? String url = "jdbc:mysql://47.122.1.22/pzj_users?"

? ? ? ? ? ? ? ? + "user=root_user&password=pzj2020@&useUnicode=true&characterEncoding=UTF8";

conn=DriverManager.getConnection(url);?

return conn;

}

public void close(Statement stat,Connection conn) throws SQLException{

if(stat!=null){

? ? ? ?stat.close();

? ? }

? ? if(conn!=null){

? ? ? ?conn.close();? ? ?

? ? }

}

public int insert(HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException{

? ? Connection conn=null;

? ? Statement stat=null;

? ? ? ? String name=request.getParameter("name");

? ? ? ? String password=request.getParameter("password");? ??

conn=connect();

stat=conn.createStatement();

int i=stat.executeUpdate("insert into shule_user values('"+name+"','"+password+"')");?

? ? close(stat,conn);

? ? return i;

? ? }

public int delete(HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException{

? ? Connection conn=null;

? ? Statement stat=null;

? ? ? ? String name=request.getParameter("name");

conn=connect();

stat=conn.createStatement();

int i=stat.executeUpdate("delete from shule_user where name ='"+name+"'");

? ? close(stat,conn);

? ? return i;

? ? }

public int change(HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException{

? ? Connection conn=null;

? ? Statement stat=null;

? ? ? ? String name=request.getParameter("name");

? ? ? ? String password=request.getParameter("password");

conn=connect();

stat=conn.createStatement();

int i=stat.executeUpdate("update shule_user set password='"+password+"' where name ='"+name+"'");

? ? close(stat,conn);

? ? return i;

? ? }

public String view(HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException{

? ? Connection conn=null;

? ? Statement stat=null;

? ? ResultSet rs=null;

? ? conn=connect();

stat=conn.createStatement();

? ? String Data="";

? ? ? ? ?rs=stat.executeQuery("select * from shule_user");?

? ? while(rs.next())

? ? ? ? {

? ? Data+=rs.getString("name")+" "+rs.getString("password")+" "+"\n";

? ? ? ? }

? ? if(rs!=null){

? ? ? rs.close();

? ? ? ?}

? ? close(stat,conn);

? ? return Data;

? ? }

}


servlet的評論 (共 條)

分享到微博請遵守國家法律
县级市| 贵州省| 衡水市| 拜城县| 竹北市| 东城区| 玛沁县| 池州市| 安庆市| 准格尔旗| 东丽区| 隆德县| 周至县| 萨迦县| 汾西县| 苗栗县| 广河县| 宾阳县| 安图县| 民勤县| 海丰县| 苍南县| 德昌县| 增城市| 万荣县| 绵竹市| 洮南市| 靖远县| 新泰市| 平武县| 塔河县| 洛隆县| 广昌县| 施秉县| 垫江县| 阳城县| 沅陵县| 大荔县| 林周县| 闻喜县| 当涂县|