{"id":3407,"date":"2015-05-14T20:48:39","date_gmt":"2015-05-15T04:48:39","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=3407"},"modified":"2024-01-10T00:58:53","modified_gmt":"2024-01-10T07:58:53","slug":"setting-up-mysql-jdbc-development-environment","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/","title":{"rendered":"Setting Up MySQL JDBC Development Environment"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to set up a development environment that allows you to work with MySQL and JDBC.<\/p>\n\n\n\n<p>To set up the development environment, you need to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Download &amp; install JDK<\/li>\n\n\n\n<li>Download and install the IntelliJ IDE<\/li>\n\n\n\n<li>Download MySQL Connector\/J<\/li>\n\n\n\n<li>Load a sample database<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Download &amp; install JDK<\/h2>\n\n\n\n<p>First, open the <a href=\"https:\/\/www.oracle.com\/java\/technologies\/downloads\/\">Java Download page and download the latest JDK<\/a>. Note that we&#8217;ll use the JDK 21.<\/p>\n\n\n\n<p>Second, install the JDK from the installer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Download &amp; Install IntelliJ IDE<\/h2>\n\n\n\n<p>First, download the IntelliJ IDE from the <a href=\"https:\/\/www.jetbrains.com\/idea\/download\/\">JetBrains website<\/a>.<\/p>\n\n\n\n<p>Second, install it on your computer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Download and install MySQL Connector\/J<\/h2>\n\n\n\n<p>First, open the <a href=\"http:\/\/dev.mysql.com\/downloads\/connector\/j\/\" rel=\"noopener\">Download Connector\/J page<\/a>.<\/p>\n\n\n\n<p>Second, select your appropriate platform and click the <strong>Download<\/strong> button. We&#8217;ll use the independent platform.<\/p>\n\n\n\n<p>It&#8217;ll take you to the login \/ sign-up page. If you don&#8217;t want to log in or sign up for an account. You can scroll down and click the link <strong>No thanks, just start my download<\/strong>.<\/p>\n\n\n\n<p>Third, extract the download file into a directory a jar file such as mysql-connector-j-8.2.0.jar. You&#8217;ll use this jar file in the next tutorial for connecting to a MySQL server from Java programs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Load MySQL JDBC sample database<\/h2>\n\n\n\n<p>We will use a sample database named <code>mysqljdbc<\/code> for the demonstration purposes. The following illustrates the database diagram:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"605\" height=\"215\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2015\/05\/mysql-jdbc-sample-database-diagram.jpg\" alt=\"mysql jdbc sample database diagram\" class=\"wp-image-3435\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2015\/05\/mysql-jdbc-sample-database-diagram.jpg 605w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2015\/05\/mysql-jdbc-sample-database-diagram-300x107.jpg 300w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/figure>\n\n\n\n<p>The sample database includes three tables:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>candidates<\/code>: stores candidate data such as first name, last name, date of birth (dob), phone, and email.<\/li>\n\n\n\n<li><code>skills<\/code>: stores skills of the candidates<\/li>\n\n\n\n<li><code>candidate_skills<\/code>: the pivot table links between candidates &amp; skills<\/li>\n<\/ul>\n\n\n\n<p>You can download the sample database via the following link:<\/p>\n\n\n\n<p><a class=\"buttonDownload\" href=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/03\/mysqljdbc.zip\" rel=\"noopener\">Download MySQL JDBC Sample Database<\/a><\/p>\n\n\n\n<p>To load the <code>mysqljdbc<\/code> sample database to the MySQL server, you follow these steps:<\/p>\n\n\n\n<p>First, extract the download file into a directory such as <code>D:\\sampledb\\mysql\\mysqljdbc.sql<\/code><\/p>\n\n\n\n<p>Second, open Command Prompt on Windows or Terminal on Unix-like systems.<\/p>\n\n\n\n<p>Third, connect to the MySQL server:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">mysql -u root -p<\/code><\/span><\/pre>\n\n\n<p>Fourth, load the database into the MySQL server using the SOURCE command:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">SOURCE D:<span class=\"hljs-regexp\">\/sampledb\/my<\/span>sql\/mysqljdbc.sql<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fifth, list all databases in the server to verify if we load the database successfully:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">SHOW DATABASES;<\/code><\/span><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">+--------------------+\n| Database           |\n+--------------------+\n| classicmodels      |\n| information_schema |\n| mysql              |\n| mysqljdbc          |\n| performance_schema |\n| sys                |\n+--------------------+\n<span class=\"hljs-number\">6<\/span> rows <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">set<\/span> (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The output shows the <code>mysqljdbc<\/code> database, meaning that we have successfully loaded the sample database into the MySQL server.<\/p>\n\n\n\n<p>In this tutorial, you have learned how to set up a development environment for working with JDBC &amp; MySQL.<\/p>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"3407\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/\"\n\t\t\t\tdata-post-title=\"Setting Up MySQL JDBC Development Environment\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"3407\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/\"\n\t\t\t\tdata-post-title=\"Setting Up MySQL JDBC Development Environment\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows you how to setup development environment that helps you work with MySQL and JDBC. It also illustrates how to load a sample database into MySQL for practicing in the subsequent tutorials.<\/p>\n","protected":false},"author":2,"featured_media":3668,"parent":3416,"menu_order":1,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-3407","page","type-page","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Setting Up MySQL JDBC Development Environment<\/title>\n<meta name=\"description\" content=\"This tutorial shows you how to setup dev environment that helps you work with MySQL and JDBC and illustrates how to load a sample database into MySQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting Up MySQL JDBC Development Environment\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you how to setup dev environment that helps you work with MySQL and JDBC and illustrates how to load a sample database into MySQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-10T07:58:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2015\/05\/mysql-jdbc-setup.png\" \/>\n\t<meta property=\"og:image:width\" content=\"120\" \/>\n\t<meta property=\"og:image:height\" content=\"100\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-jdbc-tutorial\\\/setting-up-mysql-jdbc-development-environment\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-jdbc-tutorial\\\/setting-up-mysql-jdbc-development-environment\\\/\",\"name\":\"Setting Up MySQL JDBC Development Environment\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-jdbc-tutorial\\\/setting-up-mysql-jdbc-development-environment\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-jdbc-tutorial\\\/setting-up-mysql-jdbc-development-environment\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/mysql-jdbc-setup.png\",\"datePublished\":\"2015-05-15T04:48:39+00:00\",\"dateModified\":\"2024-01-10T07:58:53+00:00\",\"description\":\"This tutorial shows you how to setup dev environment that helps you work with MySQL and JDBC and illustrates how to load a sample database into MySQL.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-jdbc-tutorial\\\/setting-up-mysql-jdbc-development-environment\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-jdbc-tutorial\\\/setting-up-mysql-jdbc-development-environment\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-jdbc-tutorial\\\/setting-up-mysql-jdbc-development-environment\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/mysql-jdbc-setup.png\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/mysql-jdbc-setup.png\",\"width\":120,\"height\":100,\"caption\":\"MySQL JDBC Setup\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-jdbc-tutorial\\\/setting-up-mysql-jdbc-development-environment\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL JDBC\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-jdbc-tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Setting Up MySQL JDBC Development Environment\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setting Up MySQL JDBC Development Environment","description":"This tutorial shows you how to setup dev environment that helps you work with MySQL and JDBC and illustrates how to load a sample database into MySQL.","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:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/","og_locale":"en_US","og_type":"article","og_title":"Setting Up MySQL JDBC Development Environment","og_description":"This tutorial shows you how to setup dev environment that helps you work with MySQL and JDBC and illustrates how to load a sample database into MySQL.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-10T07:58:53+00:00","og_image":[{"width":120,"height":100,"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2015\/05\/mysql-jdbc-setup.png","type":"image\/png"}],"twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/","url":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/","name":"Setting Up MySQL JDBC Development Environment","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2015\/05\/mysql-jdbc-setup.png","datePublished":"2015-05-15T04:48:39+00:00","dateModified":"2024-01-10T07:58:53+00:00","description":"This tutorial shows you how to setup dev environment that helps you work with MySQL and JDBC and illustrates how to load a sample database into MySQL.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2015\/05\/mysql-jdbc-setup.png","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2015\/05\/mysql-jdbc-setup.png","width":120,"height":100,"caption":"MySQL JDBC Setup"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/setting-up-mysql-jdbc-development-environment\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL JDBC","item":"https:\/\/www.mysqltutorial.org\/mysql-jdbc-tutorial\/"},{"@type":"ListItem","position":3,"name":"Setting Up MySQL JDBC Development Environment"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/3407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=3407"}],"version-history":[{"count":5,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/3407\/revisions"}],"predecessor-version":[{"id":14461,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/3407\/revisions\/14461"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/3416"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media\/3668"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=3407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}