deleting
Java’s basic method of adding, deleting, checking and modifying MySQL data through the MyBatis framework
1. Query In addition to querying a single record, here we try to query a group of records. Add the following methods to the IUserMapper interface: List getUsers(String name); Add in User.xml: select * from `user` where name like #{name} Test method: @Test public void queryListTest() { SqlSession session = sqlSessionFactory.openSession(); try { IUserMapper mapper = session.getMapper(IUserMapper.class); List users = mapper.getUsers(“%a%”); // % represents any number of characters in SQL. for (User user : users) { log.info(“{}: {}”, user.getName(), user.getAddress()); } } finally { session.close(); } } If you perform a joint table query, the returned object is a composite object, which needs to be processed using the association keyword. For example, if User publishes an Article, each user can publish multiple Articles, and there is a one-to-many relationship between them. (1) Create the Article table and insert test data: — Drop the table if exists DROP TABLE IF EXISTS `Article`; — Create a table named ‘Article’ CREATE TABLE `Article` ( `id` int NOT NULL AUTO_INCREMENT, `user_id` int NOT NULL, `title` varchar(100) NOT NULL, `content` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; –Add several test records INSERT INTO `article` VALUES (‘1’, ‘1’, ‘title1’, ‘content1’), (‘2’, ‘1’,…
JavaScript usage examples for adding, deleting, modifying and checking web page nodes
The example in this article describes the usage of Javascript for adding, deleting, modifying and checking web page nodes. Share it with everyone for your reference. The specific analysis is as follows: 1. Basic concepts This part is the so-called “HTML DOM”. The so-called HTML DOM is the Web page loading rule. It is a rule, which is the basic formula for the composition of a web page. That is, all web pages must be written according to the rules of:… and loaded according to such rules. The so-called “web page node” is also called the popular explanation of “DOM node”. For example, the content under the html node is all the content between them, and the content under the body node is all the content between them. HTML DOM is stipulated as follows: 1. The entire document is a document node; 2. Each HTML tag (meaning html tags such as , not just tags) is an element node; 3. Contained in The text in HTML elements is text nodes; 4. Each HTML attribute is an attribute node For example, a page can be drawn as the following DOM node tree: The official definition of HTML DOM is as follows:…
Some uncommon tips for adding, deleting, modifying and checking sqlserver
An Insert statement 1. Insert only default values into the data: insert into [DBTrain].[dbo].[log_info] default values 2. In a field that can be null, if you want to set null, you can press [Ctrl+0]. Note that it is zero, not o. If you want to restore the value before modification, press [Esc] Two Update statements You can update the first few items or a certain percentage of data update top(3) [log_info] set info1 = ‘1001’ update top(80) percent [log_info] set info2 = ‘1002’ Three Delete statements can also use the top keyword Four Select statements 1. With Ties Execute the following sql: select top 5 * from test order by id desc The results are shown below: Execute the following sql again to see the difference: select top 5 with ties * from test order by id desc It can be seen that the current five records have not completely displayed the data of id = 2, Use with ties to display all records with id = 2 To be continued. $identity, $RowGuid,Write clause
JavaWeb——A case of adding, deleting, modifying and checking under MVC mode
Directory MVC mode Environment configuration pom.xml mybatis-config. xml Directory structure java directory: com directory: mapper directory: pojo directory: service directory: util directory: web directory: ; resources directory: com/mapper directory: BrandMapper.xml webapp directory&# xff1a; index.html brand.jsp addBrand.jsp updateBrand.jsp MVC mode Environment configuration pom.xml 4.0.0com.myprojectbrand-demo1.0-SNAPSHOTwarmysqlmysql-connector-java8.0.21org.mybatismybatis 3.4.6javax.servletjavax.servlet-api3.1.0provided org.apache.mavenmaven-plugin-api2.0 commons-iocommons-io2.6javax.servlet.jspjsp-api2.1providedjstljstl1.2 org.apache.tomcat.maventomcat7-maven-plugin2.2 mybatis-config.xml Directory structure java directory: com directory: mapper directory: package com.mapper;import com.pojo.Brand;import java.util.List;public interface BrandMapper {List selectAll();void add(Brand brand);Brand selectById(int id);void update(Brand brand);void deletet(int id);} pojo directory: package com.pojo;/*** Brand entity class*/public class Brand {// id primary key private Integer id; // Brand name private String brandName; // Company name private String companyName; // Sorting field private Integer ordered; // Description information private String description; // Status :0:Disabled 1:Enable private Integer status;public Brand() {}public Brand(Integer id, String brandName, String companyName, String description) {this.id = id;this.brandName = brandName;this .companyName = companyName;this.description = description;} public Brand(Integer id, String brandName, String companyName, Integer ordered, String description, Integer status) {this.id = id;this .brandName = brandName;this.companyName = companyName;this.ordered = ordered;this.description = description;this.status = status;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getBrandName() {return brandName;}public void setBrandName(String brandName) {this.brandName = brandName;}public String getCompanyName() {return companyName;}public void setCompanyName(String companyName) {this.companyName = companyName;}public Integer getOrdered() {return ordered;}public…
Detailed explanation of adding, deleting, and modifying attributes of Json using JavaScript
Use JS to process Json data. When the project encounters the need to perform related operations on Json data, such as adding, deleting, and modifying operations, I thought it would be more difficult. After searching online, I found that it is relatively simple. Paste a piece of code: The above detailed explanation of the addition, deletion and modification of Json attributes by Javascript is all the content shared by the editor. I hope it can give you a reference and I hope you will support it.
Use java to write a simple student management system to implement the functions of adding, deleting, modifying and querying
Use Java to write a simple student management system to implement the functions of adding, deleting, modifying and querying Do you need one based on GUI interface or JavaWeb? These two projects have commonalities but also differences. , For example, the data layer part can be abstracted and shared in a unified manner. But there is a big difference in the view layer. Swing is a variety of business logic based on listeners, which is different from Java web development. I have implemented both recently, and I feel it is quite simple. Implementation of shopping cart function in java web. How to implement the above addition, subtraction, and deletion operations If you do not use Ajax technology, you can do three actions in the background: add(), sub(), and delete(), which represent addition, subtraction, and deletion respectively. Then the front desk makes three links for these three operations: youproject/add?id=1youproject/sub?id=1youproject/delete?id=1 If you want to make a REST-style link, you can do this: youproject/add/1youproject/sub /1youproject/delete/1The background action processes the shopping cart data after receiving the request. After the processing is completed, it returns to the front desk and refreshes the page. How to delete database information through the delete button in java web…
Some uncommon tips for adding, deleting, modifying and checking sqlserver
An Insert statement 1. Insert only default values into the data: insert into [DBTrain].[dbo].[log_info] default values 2. In a field that can be null, if you want to set null, you can press [Ctrl+0]. Note that it is zero, not o. If you want to restore the value before modification, press [Esc] Two Update statements You can update the first few items or a certain percentage of data update top(3) [log_info] set info1 = ‘1001’ update top(80) percent [log_info] set info2 = ‘1002’ Three Delete statements can also use the top keyword Four Select statements 1. With Ties Execute the following sql: select top 5 * from test order by id desc The results are shown below: Execute the following sql again to see the difference: select top 5 with ties * from test order by id desc It can be seen that the current five records have not completely displayed the data of id = 2, Use with ties to display all records with id = 2 To be continued. $identity, $RowGuid,Write clause
JavaWeb——A case of adding, deleting, modifying and checking under MVC mode
Directory MVC mode Environment configuration pom.xml mybatis-config. xml Directory structure java directory: com directory: mapper directory: pojo directory: service directory: util directory: web directory: ; resources directory: com/mapper directory: BrandMapper.xml webapp directory&# xff1a; index.html brand.jsp addBrand.jsp updateBrand.jsp MVC mode Environment configuration pom.xml 4.0.0com.myprojectbrand-demo1.0-SNAPSHOTwarmysqlmysql-connector-java8.0.21org.mybatismybatis 3.4.6javax.servletjavax.servlet-api3.1.0provided org.apache.mavenmaven-plugin-api2.0 commons-iocommons-io2.6javax.servlet.jspjsp-api2.1providedjstljstl1.2 org.apache.tomcat.maventomcat7-maven-plugin2.2 mybatis-config.xml Directory structure java directory: com directory: mapper directory: package com.mapper;import com.pojo.Brand;import java.util.List;public interface BrandMapper {List selectAll();void add(Brand brand);Brand selectById(int id);void update(Brand brand);void deletet(int id);} pojo directory: package com.pojo;/*** Brand entity class*/public class Brand {// id primary key private Integer id; // Brand name private String brandName; // Company name private String companyName; // Sorting field private Integer ordered; // Description information private String description; // Status :0:Disabled 1:Enable private Integer status;public Brand() {}public Brand(Integer id, String brandName, String companyName, String description) {this.id = id;this.brandName = brandName;this .companyName = companyName;this.description = description;} public Brand(Integer id, String brandName, String companyName, Integer ordered, String description, Integer status) {this.id = id;this .brandName = brandName;this.companyName = companyName;this.ordered = ordered;this.description = description;this.status = status;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getBrandName() {return brandName;}public void setBrandName(String brandName) {this.brandName = brandName;}public String getCompanyName() {return companyName;}public void setCompanyName(String companyName) {this.companyName = companyName;}public Integer getOrdered() {return ordered;}public…
Some uncommon tips for adding, deleting, modifying and checking sqlserver
An Insert statement 1. Insert only default values into the data: insert into [DBTrain].[dbo].[log_info] default values 2. In a field that can be null, if you want to set null, you can press [Ctrl+0]. Note that it is zero, not o. If you want to restore the value before modification, press [Esc] Two Update statements You can update the first few items or a certain percentage of data update top(3) [log_info] set info1 = ‘1001’ update top(80) percent [log_info] set info2 = ‘1002’ Three Delete statements can also use the top keyword Four Select statements 1. With Ties Execute the following sql: select top 5 * from test order by id desc The results are shown below: Execute the following sql again to see the difference: select top 5 with ties * from test order by id desc It can be seen that the current five records have not completely displayed the data of id = 2, Use with ties to display all records with id = 2 To be continued. $identity, $RowGuid,Write clause
How to write deletion and modification code in java_The complete process of adding, deleting, checking and modifying Java code
packagecom.dao;//Closing report importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.ArrayList;importjava. util.List;importcom.model.Jabg;importcom.tool.SuperUtil;public classJabgDao { Connection conn= null; PreparedStatement ptmt= null; ResultSet rs= null;//Query a single case based on id public ListselectMsg1(String id) { List list = new ArrayList() ; String sql= ” “; sql= “select * from Jabg where jabgid='”+id+ “'”;try {conn =SuperUtil.getConnection(); ptmt=conn.prepareStatement(sql); rs=ptmt .executeQuery();while(rs.next()) { Jabg u= newJabg(); u.setA_id(rs.getString(“a_id”)) ; u.setJabgid(rs.getString(“Jabgid”)); u.setDsr(rs.getString(“dsr”)); u.setAy(rs.getString(“ay”)); u.setLarq(rs.getString(“larq”)); u.setCfjdswh(rs.getString( “cfjdswh”)); u.setCfnr(rs.getString(“cfnr”)); u.setZxfs(rs.getString(“zxfs”)); p> u.setZxrq(rs.getString(“zxrq”)); u.setZxjg(rs.getString(“zxjg”)); u.setByxzcfdly (rs.getString(“byxzcfdly”)); u.setCbrqm(rs.getString(“cbrqm”)); u.setCbrqmsj(rs.getString(“cbrqmsj” )); u.setFzrspyj(rs.getString(“fzrspyj”)); u.setFzrqm(rs.getString(“fzrqm”)); u.setFzrqmsj(rs.getString(“fzrqmsj”)); u.setState(rs.getString(“state”)); u.setDelstate(rs. getString(“delstate”)); list.add(u); } SuperUtil.release(conn, ptmt, rs); p> }catch(SQLException e) {//TODO Auto-generated catch block e.printStackTrace(); }returnlist; }//Query a single case based on aid public List selectall(String jarq,String yyzz,String sfz,String ay,String jarq2,int curPage,intpageSize) {int start=(curPage-1 )*pageSize; List list = new ArrayList(); String sql= ” “; sql= “select j.a_id,a.frdbr,a.frdbrzjhm,a.dwmc,a.tyshxydm,a.frdbrzjlx,j.cfjdswh,j.larq,j.ay,x.wftk,x.cfyj,x.wfss,x. clyj,x.gzsj,j.fzrqmsj from jabg j,ajslb a,xzcfjds x where j.a_id=x.a_id and x.a_id=a.id and j.a_id=a.id and j .state=2”;if (jarq!= null && jarq.length() != 0) { sql+= ” and j. fzrqmsj >='” +jarq + “'”; }if (jarq2!= null && jarq2.length() != 0) { sql+= ” and j.fzrqmsj <='" +jarq2 + "&# 39;"; }if (yyzz!= null && yyzz.length() != 0) { sql+= ” and a.yyzz ='” +yyzz + “'”; }if (sfz!= null && sfz. length() != 0) { sql+= ” and a.frdbrzjhm like'%” +sfz…