{"id":2852,"date":"2020-04-27T18:52:18","date_gmt":"2020-04-27T13:22:18","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=2852"},"modified":"2020-04-27T22:17:15","modified_gmt":"2020-04-27T16:47:15","slug":"crud-operations-db","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/crud-operations-db\/","title":{"rendered":"CRUD Operations on DB"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">The abbreviation CRUD stands for four basic operations that can be done on persistent storage (create, read, update and delete).\u00a0 Also, these functions are mapped to standard HTTP methods. We are going to review CRUD operations on the database. All operations will be demonstrated on the MySQL database with the support of JDBC.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">JDBC (<a href=\"https:\/\/www.h2kinfosys.com\/blog\/jdbc-architecture-driver-types\/\">Java Database Connectivity<\/a>) is a part of the Java platform. JDBC provides us the possibility to connect from Java application any database (relational or non-relational). To be able to do this, JDBC API needs to utilize specific JDBC drivers.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">As we will work with the MySQL database, we need to download the library with MySQL driver. It is mysql-connector-java-8.0.11.jar. The version of the jar-file can differ.\u00a0 The MySQL driver class name is com.mysql.jdbc.Driver.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Before starting with CRUD operations, we have to connect to MySQL, to create a database and create a database table.\u00a0<\/span><\/p>\n<p><em><span style=\"text-decoration: underline;\"><span style=\"font-weight: 400;\">Let&#8217;s create Java application that will do this for us:<\/span><\/span><\/em><\/p>\n<pre><b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Connection;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.DriverManager;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.SQLException;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Statement;<\/span>\r\n\r\n<b>public<\/b> <b>class<\/b><span style=\"font-weight: 400;\"> InitDatabaseExample {<\/span>\r\n\r\n<b>public<\/b> <b>static<\/b> <b>void<\/b><span style=\"font-weight: 400;\"> main(String <\/span><span style=\"font-weight: 400;\">args<\/span><span style=\"font-weight: 400;\">[]) {<\/span>\r\n<b>try<\/b><span style=\"font-weight: 400;\"> {<\/span>\r\n<span style=\"font-weight: 400;\">Connection <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">= DriverManager.<\/span><i><span style=\"font-weight: 400;\">getConnection<\/span><\/i>\r\n<span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">\"jdbc:mysql:\/\/localhost\/?<\/span> <span style=\"font-weight: 400;\"> \u00a0 <\/span> <span style=\"font-weight: 400;\">serverTimezone=UTC&amp;useSSL=false&amp;user=root&amp;password=root\"<\/span><span style=\"font-weight: 400;\">);\u00a0<\/span>\r\n<span style=\"font-weight: 400;\">System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"We are successfully connected to\u00a0 the MySQL \u00a0 <\/span> <span style=\"font-weight: 400;\">server.\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n<span style=\"font-weight: 400;\">Statement <\/span><span style=\"font-weight: 400;\">stmt<\/span><span style=\"font-weight: 400;\">=<\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">.createStatement();<\/span>\r\n<span style=\"font-weight: 400;\">stmt<\/span><span style=\"font-weight: 400;\">.executeUpdate(<\/span><span style=\"font-weight: 400;\">\"CREATE DATABASE exampledb\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n<span style=\"font-weight: 400;\">System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"A new database with the name exampledb is\u00a0 <\/span> <span style=\"font-weight: 400;\">created.\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n<span style=\"font-weight: 400;\">stmt<\/span><span style=\"font-weight: 400;\">.close();<\/span>\r\n\r\n<span style=\"font-weight: 400;\">System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"Let's create a new table!\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n<span style=\"font-weight: 400;\">stmt<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">.createStatement();<\/span>\r\n<span style=\"font-weight: 400;\">String <\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">\"CREATE TABLE exampledb.USER (ID INT, NAME <\/span> <span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 VARCHAR(50), \"<\/span>\r\n<span style=\"font-weight: 400;\">+ <\/span><span style=\"font-weight: 400;\">\"EMAIL VARCHAR(45), CREATION_TIME DATE, PRIMARY <\/span> <span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 KEY (ID))\"<\/span><span style=\"font-weight: 400;\">;<\/span>\r\n<span style=\"font-weight: 400;\">stmt<\/span><span style=\"font-weight: 400;\">.execute(<\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n<span style=\"font-weight: 400;\">System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"The table is created successfully!\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n<span style=\"font-weight: 400;\">stmt<\/span><span style=\"font-weight: 400;\">.close();<\/span>\r\n\r\n<span style=\"font-weight: 400;\">} <\/span><b>catch<\/b><span style=\"font-weight: 400;\"> (SQLException <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLException: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getMessage());<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLState: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getSQLState());<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"VendorError: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getErrorCode());<\/span>\r\n<span style=\"font-weight: 400;\">      }<\/span>\r\n\r\n<span style=\"font-weight: 400;\">    }<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><em><span style=\"text-decoration: underline;\"><span style=\"font-weight: 400;\">The output of current applications will be:<\/span><\/span><\/em><\/p>\n<p><span style=\"font-weight: 400;\">We are successfully connected to the MySQL server.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A new database with the name exampledb is created.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s create a new table!<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The table is created successfully!<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We the result of that execution with <a href=\"https:\/\/www.h2kinfosys.com\/blog\/database-setup-mysql-oraclexe\/\">MySQL Workbench<\/a>. If you had it opened before code execution, you need to reconnect to DBMS. After this, your database with one table will appear.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The table doesn&#8217;t have data for now. You can see the current state of our database and the table on the screenshot below:<\/span><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-2853 size-full\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_45.png\" alt=\"\" width=\"737\" height=\"488\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_45.png 737w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_45-300x199.png 300w\" sizes=\"(max-width: 737px) 100vw, 737px\" \/><\/p>\n<h2><b>Create operation\u00a0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">The create operation in a relational database is represented by the SQL statement INSERT. We will go ahead and write a code snippet to create a new User in our table. We will use a PreparedStatement object got from our Connection object. To insert values into the right columns, we will use the column&#8217;s index. It worth to remind that column indexing starts from 1.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">PreparedStatement provides various set methods for each data type. Here are some of them:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">setString(int parameterIndex, String x)<br \/>\n<\/span><span style=\"font-weight: 400;\">setBoolean(int parameterIndex, boolean x)<br \/>\n<\/span><span style=\"font-weight: 400;\">setDate(int parameterIndex, Date x)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A setXXX() method have to correspond a type of column in the database table.<\/span><\/p>\n<p><em><span style=\"text-decoration: underline;\"><span style=\"font-weight: 400;\">Let&#8217;s look at our example:<\/span><\/span><\/em><\/p>\n<pre><b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Connection;<\/span>\r\n\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.DriverManager;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.PreparedStatement;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.SQLException;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Date;<\/span>\r\n\r\n<b>public<\/b> <b>class<\/b><span style=\"font-weight: 400;\"> CreationExample {<\/span>\r\n\r\n<b>public<\/b> <b>static<\/b> <b>void<\/b><span style=\"font-weight: 400;\"> main(String <\/span><span style=\"font-weight: 400;\">args<\/span><span style=\"font-weight: 400;\">[]) {<\/span>\r\n\r\n<b>try<\/b><span style=\"font-weight: 400;\"> {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">Connection <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">= DriverManager.<\/span><i><span style=\"font-weight: 400;\">getConnection<\/span><\/i>\r\n\r\n<span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">\"jdbc:mysql:\/\/localhost:3306\/exampledb?<\/span> <span style=\"font-weight: 400;\">serverTimezone=UTC&amp;useSSL=false&amp;user=root&amp;password=root\"<\/span><span style=\"font-weight: 400;\">);\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"We are succesfully connected to the MySQL <\/span> <span style=\"font-weight: 400;\">server.\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">String <\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">\"INSERT INTO User (id, name, email, creation_time) <\/span> <span style=\"font-weight: 400;\">VALUES (?, ?, ?, ?)\"<\/span><span style=\"font-weight: 400;\">;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">PreparedStatement <\/span><span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">.prepareStatement(<\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.setInt(1, 1);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.setString(2, <\/span><span style=\"font-weight: 400;\">\"TestUser\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.setString(3, <\/span><span style=\"font-weight: 400;\">\"testuser@gmail.com\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.setDate(4, <\/span><b>new<\/b><span style=\"font-weight: 400;\"> Date(<\/span><b>new<\/b><span style=\"font-weight: 400;\"> java.util.Date().getTime()));<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span>\r\n\r\n<b>int<\/b> <span style=\"font-weight: 400;\">rowsInserted<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.executeUpdate();<\/span>\r\n\r\n<b>if<\/b><span style=\"font-weight: 400;\"> (<\/span><span style=\"font-weight: 400;\">rowsInserted<\/span><span style=\"font-weight: 400;\"> &gt; 0) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"A new user was inserted successfully!\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.close();<\/span>\r\n\r\n<span style=\"font-weight: 400;\">} <\/span><b>catch<\/b><span style=\"font-weight: 400;\"> (SQLException <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLException: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getMessage());<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLState: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getSQLState());<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"VendorError: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getErrorCode());<\/span>\r\n\r\n<span style=\"font-weight: 400;\">    }<\/span>\r\n\r\n<span style=\"font-weight: 400;\">  }<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">You probably found that we have changed the connection URL string in comparison with the previous example. We added the name of the database.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The output of the application will be:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We are successfully connected to the MySQL server.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A new user was inserted successfully!<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><b>Read operation\u00a0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Now, we will look at data in our database table User. We are going to check if the new row was added and learn to work with a reading SQL statement . The read operation in a relational database is represented by the SQL statement SELECT. We can select all the data or just data from some particular columns.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here are two equal requests:[box type=&#8221;shadow&#8221; align=&#8221;&#8221; class=&#8221;&#8221; width=&#8221;&#8221;]<\/span><\/p>\n<p><span style=\"font-weight: 400;\">SELECT * FROM exampledb.user;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">SELECT user.ID, userNAME, user.EMAIL, user.CREATION_TIME FROM exampledb.user;[\/box]<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We can skip the database name from the SQL query in case we put the database name into the URL to connect to the MySQL server.\u00a0<\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><em><span style=\"font-weight: 400;\">Let&#8217;s look at code example:<\/span><\/em><\/span><\/p>\n<pre><b>package<\/b><span style=\"font-weight: 400;\"> concurrent;<\/span>\r\n\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Connection;<\/span>\r\n\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.DriverManager;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.PreparedStatement;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.ResultSet;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.SQLException;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Statement;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Date;<\/span>\r\n\r\n<b>public<\/b> <b>class<\/b><span style=\"font-weight: 400;\"> ReadExample {<\/span>\r\n<b>public<\/b> <b>static<\/b> <b>void<\/b><span style=\"font-weight: 400;\"> main(String <\/span><span style=\"font-weight: 400;\">args<\/span><span style=\"font-weight: 400;\">[]) {<\/span>\r\n<b>try<\/b><span style=\"font-weight: 400;\"> {<\/span>\r\n<span style=\"font-weight: 400;\">Connection <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">= DriverManager.<\/span><i><span style=\"font-weight: 400;\">getConnection<\/span><\/i>\r\n<span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">\"jdbc:mysql:\/\/localhost:3306\/exampledb?<\/span> <span style=\"font-weight: 400;\">serverTimezone=UTC&amp;useSSL=false&amp;user=root&amp;password=root\"<\/span><span style=\"font-weight: 400;\">);\u00a0<\/span>\r\n<span style=\"font-weight: 400;\">System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"We are successfully connected to the MySQL <\/span> <span style=\"font-weight: 400;\">server.\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n<span style=\"font-weight: 400;\">String <\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">\"SELECT * FROM user\"<\/span><span style=\"font-weight: 400;\">;<\/span>\r\n<span style=\"font-weight: 400;\">Statement <\/span><span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">.createStatement();<\/span>\r\n<span style=\"font-weight: 400;\">ResultSet <\/span><span style=\"font-weight: 400;\">result<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.executeQuery(<\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<b>while<\/b><span style=\"font-weight: 400;\"> (<\/span><span style=\"font-weight: 400;\">result<\/span><span style=\"font-weight: 400;\">.next()){<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span><b>int<\/b> <span style=\"font-weight: 400;\">id<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">result<\/span><span style=\"font-weight: 400;\">.getInt(1);<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0 String <\/span><span style=\"font-weight: 400;\">name<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">result<\/span><span style=\"font-weight: 400;\">.getString(2);<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 String <\/span><span style=\"font-weight: 400;\">email<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">result<\/span><span style=\"font-weight: 400;\">.getString(<\/span><span style=\"font-weight: 400;\">\"email\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 String <\/span><span style=\"font-weight: 400;\">date<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">result<\/span><span style=\"font-weight: 400;\">.getDate(4).toString();<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 String <\/span><span style=\"font-weight: 400;\">output<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">\"User #%d: %s - %s - %s\"<\/span><span style=\"font-weight: 400;\">;<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(String.<\/span><i><span style=\"font-weight: 400;\">format<\/span><\/i><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">output<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">id<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">name<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">email<\/span><span style=\"font-weight: 400;\">, <\/span> <span style=\"font-weight: 400;\">date<\/span><span style=\"font-weight: 400;\">));<\/span>\r\n<span style=\"font-weight: 400;\">  }<\/span>\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.close();<\/span>\r\n<span style=\"font-weight: 400;\">} <\/span><b>catch<\/b><span style=\"font-weight: 400;\"> (SQLException <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">) {<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLException: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getMessage());<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLState: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getSQLState());<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"VendorError: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getErrorCode());<\/span>\r\n<span style=\"font-weight: 400;\">     }<\/span>\r\n<span style=\"font-weight: 400;\">   }<\/span>\r\n<span style=\"font-weight: 400;\"> }<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\"><em>The output of out code:<\/em><\/span><br \/>\n<\/span><span style=\"font-weight: 400;\">We are successfully connected to the MySQL server.<br \/>\n<\/span><span style=\"font-weight: 400;\">User #1: TestUser &#8211; testuser@gmail.com \u2013 2020-04-20<\/span><\/p>\n<p><span style=\"font-weight: 400;\">After the execution of our SQL query in MySQL Workbench.<\/span><\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-2855 aligncenter\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_46.png\" alt=\"\" width=\"725\" height=\"391\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_46.png 725w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_46-300x162.png 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s look one more time at the last code example. After the execution of the SQL select query, we are getting data to the ResultSet object. We used different getXXX methods to get a property with a corresponding type. Also, there is a possibility to use columns indexes and names. The last way to get a column value by name showed in our example on the email column.\u00a0<\/span><\/p>\n<h2><b>Update operation\u00a0\u00a0\u00a0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">To update data in a relational database we use the SQL statement UPDATE. We can update a single row or a group of rows, selected by some condition. We are going to use PreparedStatement object with the setXXX() methods, the same as we did in the case of creation. Let&#8217;s update just the user email for our single user TestUser:<\/span><\/p>\n<pre><b>package<\/b><span style=\"font-weight: 400;\"> concurrent;<\/span>\r\n<b>\r\nimport<\/b><span style=\"font-weight: 400;\"> java.sql.Connection;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.DriverManager;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.PreparedStatement;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.ResultSet;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.SQLException;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Statement;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Date;<\/span>\r\n\r\n<b>public<\/b> <b>class<\/b><span style=\"font-weight: 400;\"> UpdateExample {<\/span>\r\n\r\n<b>public<\/b> <b>static<\/b> <b>void<\/b><span style=\"font-weight: 400;\"> main(String <\/span><span style=\"font-weight: 400;\">args<\/span><span style=\"font-weight: 400;\">[]) {<\/span>\r\n\r\n<b>try<\/b><span style=\"font-weight: 400;\"> {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">Connection <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">= DriverManager.<\/span><i><span style=\"font-weight: 400;\">getConnection<\/span><\/i>\r\n\r\n<span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">\"jdbc:mysql:\/\/localhost:3306\/exampledb?<\/span> <span style=\"font-weight: 400;\">serverTimezone=UTC&amp;useSSL=false&amp;user=root&amp;password=root\"<\/span><span style=\"font-weight: 400;\">);\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"We are successfully connected to the MySQL <\/span> <span style=\"font-weight: 400;\">server.\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">String <\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">\"UPDATE User SET email=? WHERE name=?\"<\/span><span style=\"font-weight: 400;\">;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">PreparedStatement <\/span><span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">.prepareStatement(<\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.setString(1, <\/span><span style=\"font-weight: 400;\">\"newEmail\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.setString(2, <\/span><span style=\"font-weight: 400;\">\"TestUser\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span>\r\n\r\n<b>int<\/b> <span style=\"font-weight: 400;\">rowsUpdated<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.executeUpdate();<\/span>\r\n\r\n<b>if<\/b><span style=\"font-weight: 400;\"> (<\/span><span style=\"font-weight: 400;\">rowsUpdated<\/span><span style=\"font-weight: 400;\"> &gt; 0) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"An existing user was updated <\/span> <span style=\"font-weight: 400;\">successfully!\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.close();<\/span>\r\n\r\n<span style=\"font-weight: 400;\">} <\/span><b>catch<\/b><span style=\"font-weight: 400;\"> (SQLException <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLException: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getMessage());<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLState: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getSQLState());<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"VendorError: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getErrorCode());<\/span>\r\n\r\n<span style=\"font-weight: 400;\">    }<\/span>\r\n\r\n<span style=\"font-weight: 400;\">  }<\/span>\r\n  \r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">In this case, the index in the setters of the PreparedStatement is the order to insert values into the SQL query. If we had more than one user with the name TestUser, we would have the value of the rowsUpdated variable &gt;1.<\/span><\/p>\n<p><em><span style=\"text-decoration: underline;\"><span style=\"font-weight: 400;\">The output of our code is:<\/span><\/span><\/em><\/p>\n<p><span style=\"font-weight: 400;\">We are successfully connected to the MySQL server.<br \/>\n<\/span><span style=\"font-weight: 400;\">An existing user was updated successfully!<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s check if the email for our user was really updated in MySQL Workbench:<\/span><\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-2856 aligncenter\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_47.png\" alt=\"\" width=\"731\" height=\"368\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_47.png 731w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_47-300x151.png 300w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Yes, we did this, the value was really updated.<\/span><\/p>\n<h2><b>Delete operation<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">We can delete data from a relational database with the use of the SQL statement DELETE.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now we are going to delete our single record from the database and check from code if our User table is empty. With DELETE SQL operation we can delete a group of rows, grouped by some condition, and even all rows from a database table.<\/span><\/p>\n<pre><b>package<\/b><span style=\"font-weight: 400;\"> concurrent;<\/span>\r\n\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Connection;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.DriverManager;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.PreparedStatement;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.ResultSet;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.SQLException;<\/span>\r\n\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Statement;<\/span>\r\n<b>import<\/b><span style=\"font-weight: 400;\"> java.sql.Date;<\/span>\r\n\r\n<b>public<\/b> <b>class<\/b><span style=\"font-weight: 400;\"> DeleteExample {<\/span>\r\n\r\n<b>public<\/b> <b>static<\/b> <b>void<\/b><span style=\"font-weight: 400;\"> main(String <\/span><span style=\"font-weight: 400;\">args<\/span><span style=\"font-weight: 400;\">[]) {<\/span>\r\n\r\n<b>try<\/b><span style=\"font-weight: 400;\"> {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">Connection <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">= DriverManager.<\/span><i><span style=\"font-weight: 400;\">getConnection<\/span><\/i>\r\n\r\n<span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">\"jdbc:mysql:\/\/localhost:3306\/exampledb?serverTimezone=UTC&amp;useSSL=false&amp;user=root&amp;password=root\"<\/span><span style=\"font-weight: 400;\">);\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"We are successfully connected to the MySQL server.\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">String <\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">\"DELETE FROM user WHERE name=?\"<\/span><span style=\"font-weight: 400;\">;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">PreparedStatement <\/span><span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">.prepareStatement(<\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.setString(1, <\/span><span style=\"font-weight: 400;\">\"TestUser\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span>\r\n\r\n<b>int<\/b> <span style=\"font-weight: 400;\">rowsDeleted<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.executeUpdate();<\/span>\r\n\r\n<b>if<\/b><span style=\"font-weight: 400;\"> (<\/span><span style=\"font-weight: 400;\">rowsDeleted<\/span><span style=\"font-weight: 400;\"> &gt; 0) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"The user was deleted successfully!\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">statement<\/span><span style=\"font-weight: 400;\">.close();<\/span>\r\n\r\n<span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">\"SELECT COUNT(*) AS total FROM user\"<\/span><span style=\"font-weight: 400;\">;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">Statement <\/span><span style=\"font-weight: 400;\">st<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">connection<\/span><span style=\"font-weight: 400;\">.createStatement();<\/span>\r\n\r\n<span style=\"font-weight: 400;\">ResultSet <\/span><span style=\"font-weight: 400;\">count<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">st<\/span><span style=\"font-weight: 400;\">.executeQuery(<\/span><span style=\"font-weight: 400;\">sql<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<b>if<\/b><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">count<\/span><span style=\"font-weight: 400;\">.next() &amp;&amp; (<\/span><span style=\"font-weight: 400;\">count<\/span><span style=\"font-weight: 400;\">.getInt(<\/span><span style=\"font-weight: 400;\">\"total\"<\/span><span style=\"font-weight: 400;\">) == 0)) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"The User table is empty!\"<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">st<\/span><span style=\"font-weight: 400;\">.close();<\/span>\r\n\r\n<span style=\"font-weight: 400;\">} <\/span><b>catch<\/b><span style=\"font-weight: 400;\"> (SQLException <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLException: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getMessage());<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"SQLState: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getSQLState());<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.<\/span><b><i>out<\/i><\/b><span style=\"font-weight: 400;\">.println(<\/span><span style=\"font-weight: 400;\">\"VendorError: \"<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">e<\/span><span style=\"font-weight: 400;\">.getErrorCode());<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"text-decoration: underline;\"><em><span style=\"font-weight: 400;\">The output of the application will be:<\/span><\/em><\/span><\/p>\n<p><span style=\"font-weight: 400;\">We are successfully connected to the MySQL server.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The user was deleted successfully!<br \/>\n<\/span><span style=\"font-weight: 400;\">The User table is empty!<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So, we reviewed CRUD operations with the support of the JDBC. Nowadays, there are a lot of frameworks that make our life easier. They can map classes for database schemas, generate all the basic CRUD operations, control transactions. The most popular frameworks for Java are the Java Persistence API, and Spring Data Java Persistence API.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The main idea is to create simple classes with fields, getters, setters. They are called entities. With the use of annotations, you need to map them to database tables (classes have to correspond tables, fields have to correspond columns). The database relationships between tables are also showing with annotations in entities. All persistence operations exist in the DAO(Data Access Object) layer or Repositories. The basic operations are usually generated by a framework, other you need to add on your own, but it looks simpler than to write just with the support of the JDBC.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The abbreviation CRUD stands for four basic operations that can be done on persistent storage (create, read, update and delete).\u00a0 Also, these functions are mapped to standard HTTP methods. We are going to review CRUD operations on the database. All operations will be demonstrated on the MySQL database with the support of JDBC. JDBC (Java [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2903,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[602,601,605,603,604],"class_list":["post-2852","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorials","tag-create-operation","tag-crud-operations","tag-delete-operation","tag-read-operation","tag-update-operation"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/2852","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=2852"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/2852\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/2903"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=2852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=2852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=2852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}