There are 3 ways to delete a data table
I. Using the Statement object
The syntax for deleting SQL statements for data table records is:
Delete from table name where specific condition
For example:
Delete from ksinfo where name = ' depopulation '
Create an SQL statement first, and then call the Executeupdate () method of the Statement object:
Stmt.executeupdate (SQL);
Two. Using the ResultSet object
Create an SQL statement first, and then call the Executeupdate () method of the Statement object. For example:
String sql = "SELECT * from ksinfo where name = ' depopulation '"; // Generating SQL statements ResultSet rs = stmt.executequery (SQL); // Get data table result set if (Rs.next ()) { rs.deleterow (); Try {Rs.updaterow ();} Catch (Exception e) {} }
Three. Using the Preparestatement object
When creating SQL statements, use parameters temporarily. Represents a value, which is then generated by the SQL statement object, and then the Preparestatement object is set to implement the deletion of a specific record. For example, the following schematic code:
sql = "Delete form ksinfo where name =?" "; = connect.preparestatement (sql); Pstmt.setstring (2, ' depopulation '); // specifying Data for a name field Pstmt.executeupdate ();
Series Articles:
Java know how much (top)Java know how much (medium)Java knows how many () Java vectors (vector) and their applicationsJava know how much (79) hash table and its applicationJava know how much (80) graphical Interface design basicsJava know how much (81) frame window BasicsJava know how much (82) Introduction to tags, buttons, and button eventsJava know how much (83) Panel Basics: JPanel and JScrollPaneJava know how much (84) layout design of graphical interfaceJava know how much (85) text box and text areaJava know how much (86) input and output of text box and text areaJava know how much (87) Select boxes and radio buttonsJava know how many (88) lists and combo boxesJava know how many (89) lists and combo boxesJava know how much (90) menuJava know how much (91) dialog boxJava know how much (92) scroll barJava know how much (93) mouse EventsJava know how much (94) keyboard EventsJava know how much (95) Drawing BasicsJava know how much (96) set the font and color of the drawingJava know how much (97) Drawing Mode OverviewHow much Java knows (98) the drawing method of the Graphics classJava know how much (graphics2d) the drawing method of the classJava know how much (100) Image processing BasicsJava know how much (101) image buffering TechnologyJava know how much (102) Multimedia FoundationJava know how much (103) network programming IP address and InetAddress classJava know how much (104) the Uniform Resource Locator URL for network programmingJava know how much (105) socket (socket)Java know how much (106) program and database connectionJava know how much (107) Several important Java database access classes and InterfacesJava know how much (108) database query IntroductionJava know how much (109) database updatesJava know how much (110) database insert recordJava know how much (111) database modification record
Java know how much (112) deleted records of database