最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
德清县| 佳木斯市| 余干县| 寿阳县| 达孜县| 青铜峡市| 仁化县| 清河县| 三都| 耒阳市| 肃南| 嘉鱼县| 宁陵县| 富川| 交口县| 田东县| 武定县| 印江| 隆化县| 乌兰察布市| 徐汇区| 荣昌县| 宁强县| 洛阳市| 信宜市| 读书| 广元市| 乌拉特前旗| 万年县| 修武县| 长乐市| 于田县| 遂昌县| 阜平县| 宝鸡市| 台中市| 威信县| 从江县| 桑植县| 荔波县| 荣成市|