{"id":48815,"date":"2017-07-31T11:00:53","date_gmt":"2017-07-31T08:00:53","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=48815"},"modified":"2019-03-05T13:05:58","modified_gmt":"2019-03-05T11:05:58","slug":"jdbc-ddl-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/","title":{"rendered":"JDBC DDL Example"},"content":{"rendered":"<p><strong>Data Definition Language (DDL)<\/strong> is a unique set of SQL commands that lets you manipulate the structure of the database. In this article, we will try to show how the JDBC <code>DDL<\/code> mechanism can be applied to a Java application.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;\n<\/p>\n<h2>1. Introduction<\/h2>\n<p>It might sound like its own programming language, but <strong>Data Definition Language (DDL)<\/strong> is really a way to view certain SQL commands. These are commands that are used to modify the structure of a database, rather than the database itself (the categorization of those commands is called Data Manipulation Language). All <code>DDL<\/code> commands are given below:<\/p>\n<ul>\n<li>CREATE<\/li>\n<li>DROP<\/li>\n<li>ALTER<\/li>\n<li>TRUNCATE<\/li>\n<li>COMMENT<\/li>\n<li>RENAME<\/li>\n<\/ul>\n<p><figure id=\"attachment_48816\" aria-describedby=\"caption-attachment-48816\" style=\"width: 619px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/how-to-learn-jdbc-ddl-commands.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48816\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/how-to-learn-jdbc-ddl-commands.jpg\" alt=\"Fig. 1: DDL Commands in SQL\" width=\"619\" height=\"336\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/how-to-learn-jdbc-ddl-commands.jpg 619w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/how-to-learn-jdbc-ddl-commands-300x163.jpg 300w\" sizes=\"(max-width: 619px) 100vw, 619px\" \/><\/a><figcaption id=\"caption-attachment-48816\" class=\"wp-caption-text\">Fig. 1: DDL Commands in SQL<\/figcaption><\/figure><\/p>\n<p>We&#8217;ll take a look at some of the major commands in <code>DDL<\/code> i.e. <code>CREATE<\/code>, <code>DROP<\/code>, <code>RENAME<\/code>, and <code>ALTER<\/code>.<\/p>\n<h3>1.1 The CREATE Command<\/h3>\n<p>The <code>CREATE<\/code> command is used to <em>create a table or a database<\/em>. Since we are dealing with the structure of the database, will not insert any data into the table; the command simply builds the table for use. The syntax for the command is given below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Create Database<\/em><\/span><\/p>\n<pre class=\"brush:sql; wrap-lines:false;\">CREATE DATABASE database_name;\n<\/pre>\n<p>The <code>create table<\/code> command requires a table name and at least one column with its corresponding data type (For e.g.: Text, Numeric etc.).<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Create Table<\/em><\/span><\/p>\n<pre class=\"brush:sql; wrap-lines:false;\">CREATE TABLE table_name (\n    Column_1 data_type,\n    Column_2 data_type,\n    ...\n);\n<\/pre>\n<h3>1.2 The DROP Command<\/h3>\n<p>The <code>DROP<\/code> command is used to <em>drop a database or a table from the database<\/em>. When a table is dropped, all the data goes with it. However, for this lesson, we are only concerned with tweaking the structure. The syntax for the command is given below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Drop Database<\/em><\/span><\/p>\n<pre class=\"brush:sql; wrap-lines:false;\">DROP DATABASE database_name;\n<\/pre>\n<p>The syntax to <code>DROP<\/code> a table from the database is as follow,<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Drop Table<\/em><\/span><\/p>\n<pre class=\"brush:sql; wrap-lines:false;\">DROP TABLE table_name;\n<\/pre>\n<p><strong>Note<\/strong>: Be careful while dropping a table. Dropping a table will result in loss of complete information stored in the table.<\/p>\n<h3>1.3 The ALTER Command<\/h3>\n<p>The <code>DROP<\/code> command is quite extreme, as it completely wipes out the table and any data in it. However, when the data exists in the table(s) of our database, modifying the structure is easier through other means, such as <code>ALTER<\/code>. <code>ALTER<\/code> is used to <em>add<\/em>, <em>change<\/em>, or <em>remove<\/em> columns or fields in the table. It can also be used to rename the table.<\/p>\n<p>Let&#8217;s break this one down a little and look at each option:<\/p>\n<ul>\n<li>Adding column(s)<\/li>\n<li>Modifying column(s)<\/li>\n<li>Removing columns<\/li>\n<\/ul>\n<h4>1.3.1 Add Column(s)<\/h4>\n<p>In order to add a new column, the <code>ALTER<\/code> command requires syntax similar to the <code>CREATE<\/code> statement. The table name is required and so are the column names or the definitions. The syntax for the command is given below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Add Column<\/em><\/span><\/p>\n<pre class=\"brush:sql; wrap-lines:false;\">ALTER TABLE table_name ADD COLUMN column_name_1 data_type, column_name_2 data_type;\n<\/pre>\n<h4>1.3.2 Modify a Column<\/h4>\n<p>The <code>MODIFY<\/code> commands allow you to:<\/p>\n<ul>\n<li>Modify Column Data Type.<\/li>\n<li>Modify Column Constraints.<\/li>\n<\/ul>\n<p>This command requires the table name, the column name(s), and the column data-type(s). The syntax for the command is given below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Modify Column<\/em><\/span><\/p>\n<pre class=\"brush:sql; wrap-lines:false;\">ALTER TABLE table_name MODIFY COLUMN column_name data_type;\n<\/pre>\n<p>Suppose that we want to <em>add a new column at a specific position in the table<\/em>. We can use the <code>ALTER<\/code> command together with the <code>AFTER<\/code> keyword.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>After Keyword<\/em><\/span><\/p>\n<pre class=\"brush:sql; wrap-lines:false;\">ALTER TABLE table_name ADD COLUMN column_name data_type AFTER column_name_1;\n<\/pre>\n<h4>1.3.3 Remove a Column<\/h4>\n<p>The <code>DROP COLUMN<\/code> command is used to delete a column from the table structure. The syntax for the command is given below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Drop Column<\/em><\/span><\/p>\n<pre class=\"brush:sql; wrap-lines:false;\">ALTER TABLE table_name DROP COLUMN column_name;\n<\/pre>\n<h3>1.4 The RENAME Command<\/h3>\n<p>The <code>RENAME<\/code> command is used to <em>change the name of an existing database object (like Table, Column) to a new name<\/em>. Renaming a table does not make it lose any data that is contained within it. The syntax for the command is given below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Rename Table<\/em><\/span><\/p>\n<pre class=\"brush:sql; wrap-lines:false;\">RENAME TABLE current_table_name TO new_table_name;\n<\/pre>\n<h3>1.5 What is Statement in JDBC?<\/h3>\n<ul>\n<li>The <code>java.sql.Statement<\/code> object is used for executing a static SQL statement and returning the results it produces.<\/li>\n<li>Statement cannot accept parameters at runtime in Java JDBC.<\/li>\n<li>Statement is slower as compared to <code>PreparedStatement<\/code> in java JDBC.<\/li>\n<li>Statement is suitable for executing <code>DDL<\/code> commands &#8211; <code>CREATE<\/code>, <code>DROP<\/code>, <code>ALTER<\/code>, and <code>TRUNCATE<\/code> in Java JDBC.<\/li>\n<li>Statement can\u2019t be used for storing or retrieving images and files in the database (i.e. using BLOB, CLOB data types) in Java JDBC.<\/li>\n<li>Statement enforces SQL injection because we end up using query formed by <em>concatenated SQL strings<\/em> in Java JDBC.<\/li>\n<li><code>java.sql.Statement<\/code>&nbsp;important methods in Java JDBC are:\n<ul>\n<li><a href=\"http:\/\/www.javamadesoeasy.com\/2015\/07\/jdbc-statement-example-execute-create.html\" target=\"_blank\" rel=\"noopener noreferrer\">executeUpdate<\/a><\/li>\n<li><a href=\"http:\/\/www.javamadesoeasy.com\/2015\/07\/jdbc-statement-example-execute-select.html\" target=\"_blank\" rel=\"noopener noreferrer\">executeQuery<\/a><\/li>\n<li><a href=\"http:\/\/www.javamadesoeasy.com\/2015\/07\/jdbc-batch-statement-example-execute.html\" target=\"_blank\" rel=\"noopener noreferrer\">executeBatch<\/a><\/li>\n<li><a href=\"http:\/\/www.javamadesoeasy.com\/2015\/07\/jdbc-execute-insert-query-using.html\" target=\"_blank\" rel=\"noopener noreferrer\">execute<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>1.6 Download and Install MySQL<\/h3>\n<p>You can watch <a href=\"https:\/\/www.youtube.com\/watch?v=z1t9m7K6cpI\" target=\"_blank\" rel=\"noopener noreferrer\">this<\/a> video in order to download and install the MySQL database on your windows operations system.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Now, open up the Eclipse IDE and let\u2019s start building the application!<\/p>\n<h2>2. JDBC Connection Pool Example<\/h2>\n<h3>2.1 Tools Used<\/h3>\n<p>We are using Eclipse Kepler SR2, JDK 8, MySQL database and Maven (to download the MySQL connector and Log4J library). Having said that, we have tested the code against JDK 1.7 and it works well.<\/p>\n<h3>2.2 Project Structure<\/h3>\n<p>Firstly, let\u2019s review the final project structure, in case you are confused about where you should create the corresponding files or folder later!<\/p>\n<p><figure id=\"attachment_48817\" aria-describedby=\"caption-attachment-48817\" style=\"width: 252px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-structure.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48817\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-structure.jpg\" alt=\"Fig. 2: JDBC DDL Application Project Structure\" width=\"252\" height=\"308\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-structure.jpg 252w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-structure-245x300.jpg 245w\" sizes=\"(max-width: 252px) 100vw, 252px\" \/><\/a><figcaption id=\"caption-attachment-48817\" class=\"wp-caption-text\">Fig. 2: JDBC DDL Application Project Structure<\/figcaption><\/figure><\/p>\n<h3>2.3 Project Creation<\/h3>\n<p>This section will demonstrate on how to create a Dynamic Web Java Maven project with Eclipse. In Eclipse IDE, go to <code>File -&gt; New -&gt; Maven Project<\/code><\/p>\n<p><figure id=\"attachment_48818\" aria-describedby=\"caption-attachment-48818\" style=\"width: 652px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48818\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-1.jpg\" alt=\"Fig. 3: Create Maven Project\" width=\"652\" height=\"712\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-1.jpg 652w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-1-275x300.jpg 275w\" sizes=\"(max-width: 652px) 100vw, 652px\" \/><\/a><figcaption id=\"caption-attachment-48818\" class=\"wp-caption-text\">Fig. 3: Create Maven Project<\/figcaption><\/figure><\/p>\n<p>In the New Maven Project window, it will ask you to select project location. By default, &#8216;<em>Use default workspace location<\/em>&#8216; will be selected. Select the &#8216;<em>Create a simple project (skip archetype selection)<\/em>&#8216; checkbox and just click on next button to proceed.<\/p>\n<p><figure id=\"attachment_48819\" aria-describedby=\"caption-attachment-48819\" style=\"width: 804px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48819\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-2.jpg\" alt=\"Fig. 4: Project Details\" width=\"804\" height=\"541\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-2.jpg 804w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-2-300x202.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-2-768x517.jpg 768w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><\/a><figcaption id=\"caption-attachment-48819\" class=\"wp-caption-text\">Fig. 4: Project Details<\/figcaption><\/figure><\/p>\n<p>It will ask you to &#8216;Enter a group id for the artifact.&#8217; We will input the details as shown in the below image. The version number will be by default <code>0.0.1-SNAPSHOT<\/code>.<\/p>\n<p><figure id=\"attachment_48820\" aria-describedby=\"caption-attachment-48820\" style=\"width: 598px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48820\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-3.jpg\" alt=\"Fig. 5: Archetype Parameters\" width=\"598\" height=\"544\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-3.jpg 598w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-3-300x273.jpg 300w\" sizes=\"(max-width: 598px) 100vw, 598px\" \/><\/a><figcaption id=\"caption-attachment-48820\" class=\"wp-caption-text\">Fig. 5: Archetype Parameters<\/figcaption><\/figure><\/p>\n<p>Click on Finish and now creating a maven project is completed. If you observe, it has downloaded the maven dependencies and a <code>pom.xml<\/code> file will be created. It will have the following code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n\t&lt;groupId&gt;JdbcDdl&lt;\/groupId&gt;\n\t&lt;artifactId&gt;JdbcDdl&lt;\/artifactId&gt;\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n&lt;\/project&gt;\n<\/pre>\n<p>We can start adding the dependencies that developers want like MySQL, Log4J Jars etc. Let\u2019s start building the application!<\/p>\n<h2>3. Application Building<\/h2>\n<p>Below are the steps involved in developing this application:<\/p>\n<h3>3.1 Maven Dependencies<\/h3>\n<p>In this example, we are using latest MySQL version i.e. <code>mysql-connector-java-5.1.21<\/code> and Log4J dependencies. The <strong>updated<\/strong> file will have the following code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n\txsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n\t&lt;groupId&gt;JdbcDdl&lt;\/groupId&gt;\n\t&lt;artifactId&gt;JdbcDdl&lt;\/artifactId&gt;\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n\t&lt;packaging&gt;jar&lt;\/packaging&gt;\n\t&lt;dependencies&gt;\n\t\t&lt;dependency&gt;\n\t\t\t&lt;groupId&gt;mysql&lt;\/groupId&gt;\n\t\t\t&lt;artifactId&gt;mysql-connector-java&lt;\/artifactId&gt;\n\t\t\t&lt;version&gt;5.1.21&lt;\/version&gt;\n\t\t&lt;\/dependency&gt;\n\t\t&lt;dependency&gt;\n\t\t\t&lt;groupId&gt;log4j&lt;\/groupId&gt;\n\t\t\t&lt;artifactId&gt;log4j&lt;\/artifactId&gt;\n\t\t\t&lt;version&gt;1.2.16&lt;\/version&gt;\n\t\t&lt;\/dependency&gt;\n\t&lt;\/dependencies&gt;\n\t&lt;build&gt;\n\t\t&lt;finalName&gt;${project.artifactId}&lt;\/finalName&gt;\n\t&lt;\/build&gt;\n&lt;\/project&gt;\n<\/pre>\n<h3>3.2 Java Class Creation<\/h3>\n<p>Let\u2019s create the required java files. Right click on <code>src\/main\/java<\/code> folder, <code>New -&gt; Package<\/code>.<\/p>\n<p><figure id=\"attachment_48821\" aria-describedby=\"caption-attachment-48821\" style=\"width: 677px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48821\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-4.jpg\" alt=\"Fig. 6: Java Package Creation\" width=\"677\" height=\"659\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-4.jpg 677w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-4-300x292.jpg 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a><figcaption id=\"caption-attachment-48821\" class=\"wp-caption-text\">Fig. 6: Java Package Creation<\/figcaption><\/figure><\/p>\n<p>A new pop window will open where we will enter the package name as <code>com.jcg.jdbc.ddl.example<\/code>.<\/p>\n<p><figure id=\"attachment_48822\" aria-describedby=\"caption-attachment-48822\" style=\"width: 517px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48822\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-5.jpg\" alt=\"Fig. 7: Java Package Name (com.jcg.jdbc.ddl.example)\" width=\"517\" height=\"426\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-5.jpg 517w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-5-300x247.jpg 300w\" sizes=\"(max-width: 517px) 100vw, 517px\" \/><\/a><figcaption id=\"caption-attachment-48822\" class=\"wp-caption-text\">Fig. 7: Java Package Name (com.jcg.jdbc.ddl.example)<\/figcaption><\/figure><\/p>\n<p>Once the package is created in the application, we will need to create the implementation class. Right click on the newly created package, <code>New -&gt; Class<\/code>.<\/p>\n<p><figure id=\"attachment_48823\" aria-describedby=\"caption-attachment-48823\" style=\"width: 717px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-6.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48823\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-6.jpg\" alt=\"Fig. 8: Java Class Creation\" width=\"717\" height=\"657\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-6.jpg 717w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-6-300x275.jpg 300w\" sizes=\"(max-width: 717px) 100vw, 717px\" \/><\/a><figcaption id=\"caption-attachment-48823\" class=\"wp-caption-text\">Fig. 8: Java Class Creation<\/figcaption><\/figure>[ulp id=&#8217;TD36VgQCKfhTAygK&#8217;]<\/p>\n<p>A new pop window will open and enter the file name as <code>JdbcDdlExample<\/code>. The implementation class will be created inside the package: <code>com.jcg.jdbc.ddl.example<\/code>.<\/p>\n<p><figure id=\"attachment_48824\" aria-describedby=\"caption-attachment-48824\" style=\"width: 536px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-7.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48824\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-7.jpg\" alt=\"Fig. 9: Java Class (JdbcDdlExample.java)\" width=\"536\" height=\"630\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-7.jpg 536w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-guide-7-255x300.jpg 255w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a><figcaption id=\"caption-attachment-48824\" class=\"wp-caption-text\">Fig. 9: Java Class (JdbcDdlExample.java)<\/figcaption><\/figure><\/p>\n<h4>3.2.1 Implementation of Main Class<\/h4>\n<p>This is the implementation class where we will be issuing the <code>DDL<\/code> commands via JDBC statement. To issue a statement, we call the <code>statementObj.execute()<\/code> method. Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>JdbcDdlExample.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.jcg.jdbc.ddl.example;\n\nimport java.sql.Connection;\nimport java.sql.DatabaseMetaData;\nimport java.sql.DriverManager;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\nimport java.sql.Statement;\n\nimport org.apache.log4j.Logger;\n\npublic class JdbcDdlExample implements DbQueryConstants {\n\n\t\/\/ JDBC Driver Name &amp; Database URL\n\tstatic final String JDBC_DRIVER = \"com.mysql.jdbc.Driver\";  \n\tstatic final String JDBC_DB_URL = \"jdbc:mysql:\/\/localhost:3306\";\n\n\t\/\/ JDBC Database Credentials\n\tstatic final String JDBC_USER = \"root\";\n\tstatic final String JDBC_PASS = \"\";\n\n\tpublic final static Logger logger = Logger.getLogger(JdbcDdlExample.class);\n\n\tpublic static void main(String[] args) {\n\n\t\tConnection connObj = null;\n\t\tStatement stmtOBj = null;\n\t\ttry {\n\t\t\tClass.forName(JDBC_DRIVER);\n\t\t\tconnObj = DriverManager.getConnection(JDBC_DB_URL, JDBC_USER, JDBC_PASS);\n\n\t\t\tstmtOBj = connObj.createStatement();\n\n\t\t\t\/\/ DDL Statement 1 - Create Database Schema!\n\t\t\tlogger.info(\"\\n=======CREATE \" + DATABASE_NAME + \" DATABASE=======\");\t\t\t\n\t\t\tstmtOBj.executeUpdate(CREATE_DATABASE_QUERY);\n\t\t\tlogger.info(\"\\n=======DATABASE IS SUCCESSFULLY CREATED=======\\n\");\n\n\t\t\tlogger.info(\"\\n=======USING \" + DATABASE_NAME + \" DATABASE=======\\n\");\n\t\t\tstmtOBj.executeUpdate(USE_DATABASE_QUERY);\n\n\t\t\t\/\/ DDL Statement 2 - Create Table!\n\t\t\tlogger.info(\"\\n=======CREATE \" + TABLE_NAME + \" TABLE=======\");\t\t\t\n\t\t\tstmtOBj.executeUpdate(CREATE_TABLE_QUERY);\n\t\t\tlogger.info(\"\\n=======TABLE IS SUCCESSFULLY CREATED=======\\n\");\n\n\t\t\tlogger.info(\"\\n=======SHOW TABLE STRUCTURE=======\");\n\t\t\tshowDbTableStructure();\n\n\t\t\t\/\/ DDL Statement 3(a) - Alter Table Column!\n\t\t\tlogger.info(\"\\n=======ALTER \" + TABLE_NAME + \" TABLE=======\");\n\t\t\tstmtOBj.executeUpdate(ALTER_TABLE_QUERY);\n\t\t\tlogger.info(\"\\n=======TABLE IS SUCCESSFULLY ALTERED=======\\n\");\n\n\t\t\tlogger.info(\"\\n=======SHOW TABLE STRUCTURE=======\");\n\t\t\tshowDbTableStructure();\n\n\t\t\t\/\/ DDL Statement 3(b) - Alter Table Column Using After Clause!\n\t\t\tlogger.info(\"\\n=======ALTER \" + TABLE_NAME + \" TABLE WITH AFTER CLAUSE=======\");\n\t\t\tstmtOBj.executeUpdate(ALTER_TABLE_WITH_AFTER_CLAUSE_QUERY);\n\t\t\tlogger.info(\"\\n=======TABLE IS SUCCESSFULLY ALTERED=======\\n\");\n\n\t\t\tlogger.info(\"\\n=======SHOW TABLE STRUCTURE=======\");\n\t\t\tshowDbTableStructure();\t\t\t\n\n\t\t\t\/\/ DDL Statement 4(a) - Drop Table Column!\n\t\t\tlogger.info(\"\\n=======DROP COLUMN=======\");\n\t\t\tstmtOBj.executeUpdate(DROP_COLUMN);\n\t\t\tlogger.info(\"\\n=======COLUMN IS SUCCESSFULLY DROPPED FROM THE TABLE=======\\n\");\n\n\t\t\tlogger.info(\"\\n=======SHOW TABLE STRUCTURE=======\");\n\t\t\tshowDbTableStructure();\t\n\n\t\t\t\/\/ DDL Statement 4(b) - Drop Table!\n\t\t\tlogger.info(\"\\n=======DROP TABLE=======\");\n\t\t\tstmtOBj.executeUpdate(DROP_TABLE);\n\t\t\tlogger.info(\"\\n=======TABLE IS SUCCESSFULLY DROPPED FROM THE DATABASE=======\\n\");\n\n\t\t\t\/\/ DDL Statement 4(c) - Drop Database!\n\t\t\tlogger.info(\"\\n=======DROP DATABASE=======\");\n\t\t\tstmtOBj.executeUpdate(DROP_DATABASE);\n\t\t\tlogger.info(\"\\n=======DATABASE IS SUCCESSFULLY DROPPED=======\");\n\t\t} catch(Exception sqlException) {\n\t\t\tsqlException.printStackTrace();\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tif(stmtOBj != null) {\n\t\t\t\t\tstmtOBj.close();\t\/\/ Close Statement Object\n\t\t\t\t}\n\t\t\t\tif(connObj != null) {\n\t\t\t\t\tconnObj.close();\t\/\/ Close Connection Object\n\t\t\t\t}\n\t\t\t} catch (Exception sqlException) {\n\t\t\t\tsqlException.printStackTrace();\n\t\t\t}\n\t\t}\n\t}\n\n\t\/\/ This Method Is Used To Print The Table Structure\n\tprivate static void showDbTableStructure() throws SQLException {\n\t\tStringBuilder builderObj = new StringBuilder();\n\t\tDatabaseMetaData metaObj = DriverManager.getConnection(JDBC_DB_URL, JDBC_USER, JDBC_PASS).getMetaData();\n\t\tResultSet resultSetObj = metaObj.getColumns(DATABASE_NAME, null, TABLE_NAME, \"%\");\n\n\t\tbuilderObj.append(TABLE_NAME + \" Columns Are?= (\");\n\t\twhile (resultSetObj.next()) {\n\t\t\tString columnName = resultSetObj.getString(4);\n\t\t\tbuilderObj.append(columnName).append(\", \");\n\t\t}\n\t\tbuilderObj.deleteCharAt(builderObj.lastIndexOf(\",\")).deleteCharAt(builderObj.lastIndexOf(\" \")).append(\")\").append(\"\\n\");\n\t\tlogger.info(builderObj.toString());\n\t}\n}\n<\/pre>\n<h2>4. Run the Application<\/h2>\n<p>To run the application, Right click on the <code>JdbcDdlExample<\/code> class, <code>Run As -&gt; Java Application<\/code>.<\/p>\n<p><figure id=\"attachment_48826\" aria-describedby=\"caption-attachment-48826\" style=\"width: 829px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-deploy-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48826\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-deploy-1.jpg\" alt=\"Fig. 10: Run Application\" width=\"829\" height=\"676\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-deploy-1.jpg 829w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-deploy-1-300x245.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-project-deploy-1-768x626.jpg 768w\" sizes=\"(max-width: 829px) 100vw, 829px\" \/><\/a><figcaption id=\"caption-attachment-48826\" class=\"wp-caption-text\">Fig. 10: Run Application<\/figcaption><\/figure><\/p>\n<h2>5. Project Demo<\/h2>\n<p>The code shows the following status as output:<\/p>\n<ul>\n<li><code>CREATE<\/code> Statement<\/li>\n<\/ul>\n<p>Create Database:<\/p>\n<p><figure id=\"attachment_48828\" aria-describedby=\"caption-attachment-48828\" style=\"width: 848px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48828\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-1.jpg\" alt=\"Fig. 11: Create Database Schema\" width=\"848\" height=\"47\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-1.jpg 848w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-1-300x17.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-1-768x43.jpg 768w\" sizes=\"(max-width: 848px) 100vw, 848px\" \/><\/a><figcaption id=\"caption-attachment-48828\" class=\"wp-caption-text\">Fig. 11: Create Database Schema<\/figcaption><\/figure><\/p>\n<p>Create Table:<\/p>\n<p><figure id=\"attachment_48829\" aria-describedby=\"caption-attachment-48829\" style=\"width: 848px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48829\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-2.jpg\" alt=\"Fig. 12: Create Table in a Database\" width=\"848\" height=\"122\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-2.jpg 848w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-2-300x43.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-2-768x110.jpg 768w\" sizes=\"(max-width: 848px) 100vw, 848px\" \/><\/a><figcaption id=\"caption-attachment-48829\" class=\"wp-caption-text\">Fig. 12: Create Table in a Database<\/figcaption><\/figure><\/p>\n<ul>\n<li><code>ALTER<\/code> Statement<\/li>\n<\/ul>\n<p>Alter Table:<\/p>\n<p><figure id=\"attachment_48830\" aria-describedby=\"caption-attachment-48830\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48830\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-3.jpg\" alt=\"Fig. 13: Alter Table (i.e. Add New Column)\" width=\"849\" height=\"91\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-3.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-3-300x32.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-3-768x82.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-48830\" class=\"wp-caption-text\">Fig. 13: Alter Table (i.e. Add New Column)<\/figcaption><\/figure><\/p>\n<p>Alter Table with After Keyword:<\/p>\n<p><figure id=\"attachment_48831\" aria-describedby=\"caption-attachment-48831\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48831\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-4.jpg\" alt=\"Fig. 14: Alter Table with After Keyword\" width=\"849\" height=\"86\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-4.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-4-300x30.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-4-768x78.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-48831\" class=\"wp-caption-text\">Fig. 14: Alter Table with After Keyword<\/figcaption><\/figure><\/p>\n<ul>\n<li><code>DROP<\/code> Statement<\/li>\n<\/ul>\n<p>Drop Column:<\/p>\n<p><figure id=\"attachment_48833\" aria-describedby=\"caption-attachment-48833\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48833\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-5.jpg\" alt=\"Fig. 15: Drop Column from Table\" width=\"849\" height=\"92\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-5.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-5-300x33.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-5-768x83.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-48833\" class=\"wp-caption-text\">Fig. 15: Drop Column from Table<\/figcaption><\/figure><\/p>\n<p>Drop Table &amp; Database:<\/p>\n<p><figure id=\"attachment_48834\" aria-describedby=\"caption-attachment-48834\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-6.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48834\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-6.jpg\" alt=\"Fig. 16: Drop Table &amp; Database Schema\" width=\"849\" height=\"101\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-6.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-6-300x36.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-ddl-example-output-6-768x91.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-48834\" class=\"wp-caption-text\">Fig. 16: Drop Table &amp; Database Schema<\/figcaption><\/figure><\/p>\n<p>That\u2019s all for this post. Happy Learning!!<\/p>\n<h2>6. Conclusion<\/h2>\n<p>Here, we understood what are <code>DDL<\/code> statements and how we can implement the same in Java.<\/p>\n<h2>7. Download the Eclipse Project<\/h2>\n<p>This was an example of JDBC DDL Commands.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/Jdbc-Ddl.zip\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Jdbc Ddl<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Data Definition Language (DDL) is a unique set of SQL commands that lets you manipulate the structure of the database. In this article, we will try to show how the JDBC DDL mechanism can be applied to a Java application. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1. Introduction It might sound like its own &hellip;<\/p>\n","protected":false},"author":119,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[216,700],"class_list":["post-48815","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql","tag-jdbc-2","tag-statement"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JDBC DDL Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this article, we will try to show how the JDBC DDL (Data Definition Language) mechanism can be applied to a Java application.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JDBC DDL Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this article, we will try to show how the JDBC DDL (Data Definition Language) mechanism can be applied to a Java application.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-07-31T08:00:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-05T11:05:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"JDBC DDL Example\",\"datePublished\":\"2017-07-31T08:00:53+00:00\",\"dateModified\":\"2019-03-05T11:05:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/\"},\"wordCount\":1340,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"jdbc\",\"statement\"],\"articleSection\":[\"sql\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/\",\"name\":\"JDBC DDL Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2017-07-31T08:00:53+00:00\",\"dateModified\":\"2019-03-05T11:05:58+00:00\",\"description\":\"In this article, we will try to show how the JDBC DDL (Data Definition Language) mechanism can be applied to a Java application.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"sql\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"JDBC DDL Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JDBC DDL Example - Java Code Geeks","description":"In this article, we will try to show how the JDBC DDL (Data Definition Language) mechanism can be applied to a Java application.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/","og_locale":"en_US","og_type":"article","og_title":"JDBC DDL Example - Java Code Geeks","og_description":"In this article, we will try to show how the JDBC DDL (Data Definition Language) mechanism can be applied to a Java application.","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-07-31T08:00:53+00:00","article_modified_time":"2019-03-05T11:05:58+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"JDBC DDL Example","datePublished":"2017-07-31T08:00:53+00:00","dateModified":"2019-03-05T11:05:58+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/"},"wordCount":1340,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["jdbc","statement"],"articleSection":["sql"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/","name":"JDBC DDL Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2017-07-31T08:00:53+00:00","dateModified":"2019-03-05T11:05:58+00:00","description":"In this article, we will try to show how the JDBC DDL (Data Definition Language) mechanism can be applied to a Java application.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-ddl-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"sql","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/"},{"@type":"ListItem","position":5,"name":"JDBC DDL Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/48815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=48815"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/48815\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=48815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=48815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=48815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}