{"id":41941,"date":"2024-05-22T12:00:11","date_gmt":"2024-05-22T12:00:11","guid":{"rendered":"https:\/\/accuweb.cloud\/resource\/?post_type=faq&#038;p=41941"},"modified":"2026-02-19T05:12:46","modified_gmt":"2026-02-19T05:12:46","slug":"database-connection-via-jndi","status":"publish","type":"faq","link":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-jndi","title":{"rendered":"How to Make a Connection to DB using JNDI?"},"content":{"rendered":"<h2 class=\"ack-h2\">How to Make a Connection to DB using JNDI?<\/h2>\n<p>JNDI, or the <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/application\/java-hosting\" target=\"_blank\" rel=\"noopener\">Java<\/a> Naming and Directory Interface, is a tool in Java that helps consistently manage names and directory services. It helps bind objects together, look up or search for objects, and notice any changes made to those objects.<\/p>\n<p>To use JNDI, you need to understand the service it&#8217;s working with and have access to that service&#8217;s setup. For example, if you&#8217;re connecting to a database, you&#8217;ll need to know certain details about the database and how to handle any issues that may arise.<\/p>\n<p>Now, let&#8217;s learn how to connect a database using JNDI through <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/\" target=\"_blank\" rel=\"noopener\">Accuweb.cloud<\/a> dashboard.<\/p>\n<p><strong>Step 1.<\/strong> <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/login\" target=\"_blank\" rel=\"noopener\">Log in<\/a> to your AccuWeb.cloud dashboard.<\/p>\n<p><strong>Step 2.<\/strong> Create a new environment with a MySQL or MariaDB database. If you already have an environment with a <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/database\/mysql-hosting\" target=\"_blank\" rel=\"noopener\">MySQL<\/a> database, you can use that to connect with JNDI.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-01.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-41759 size-full\" title=\"Create a New Environment\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-01.jpg\" alt=\"Create a New Environment\" width=\"1219\" height=\"758\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-01.jpg 1219w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-01-300x187.jpg 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-01-1024x637.jpg 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-01-768x478.jpg 768w\" sizes=\"(max-width: 1219px) 100vw, 1219px\" \/><\/a><\/p>\n<p><strong>Step 3.<\/strong> Use the login details received via email to log in to the database. Create a new database with the following details:<\/p>\n<ul class=\"ack-ul\">\n<li><strong>Database name:<\/strong> accuweb_db<\/li>\n<li><strong>User name:<\/strong> accuweb<\/li>\n<li><strong>Password:<\/strong> AccU@12345<\/li>\n<\/ul>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-02.jpg\"><img decoding=\"async\" class=\"ack-article-image aligncenter wp-image-41758 size-full\" title=\"Create a New Database\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-02.jpg\" alt=\"Create a New Database\" width=\"1247\" height=\"700\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-02.jpg 1247w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-02-300x168.jpg 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-02-1024x575.jpg 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-02-768x431.jpg 768w\" sizes=\"(max-width: 1247px) 100vw, 1247px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-032.jpg\"><img decoding=\"async\" class=\"ack-article-image aligncenter wp-image-41761 size-full\" title=\"Login Information\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-032.jpg\" alt=\"Login Information\" width=\"1230\" height=\"960\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-032.jpg 1230w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-032-300x234.jpg 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-032-1024x799.jpg 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-032-768x599.jpg 768w\" sizes=\"(max-width: 1230px) 100vw, 1230px\" \/><\/a><\/p>\n<p><strong>Step 4.<\/strong> Go to the configuration files (conf) of your web application and make changes to context.xml and web.xml files. The default path for the web application&#8217;s configuration is<strong> \/opt\/tomcat\/conf\/.<\/strong><\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-41760 size-full\" title=\"web.xml files\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047.jpg\" alt=\"web.xml files\" width=\"1018\" height=\"570\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047.jpg 1018w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047-300x168.jpg 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047-768x430.jpg 768w\" sizes=\"(max-width: 1018px) 100vw, 1018px\" \/><\/a><\/p>\n<h2 class=\"ack-h2\">In context.xml<\/h2>\n<div class=\"article-space\"><\/div>\n<pre><code class=\"language-javascript\">\r\n&lt;Context antiJARLocking=\"true\" path=\"\/JNDI\"&gt;\r\n&lt;Resource name=\"jdbc\/jelasticDb\" auth=\"Container\" type=\"javax.sql.DataSource\"\r\nmaxActive=\"100\" maxIdle=\"30\" maxWait=\"10000\"\r\nusername=\"accuweb\" password=\"AccU@12345\" driverClassName=\"com.mysql.jdbc.Driver\"\r\nurl=\"jdbc:mysql:\/\/node5132-accu-connection-db-using-jndi.us-accuweb.cloud\/accuweb_db\"\/&gt;\r\n&lt;\/Context&gt;<\/code><\/pre>\n<div class=\"article-extra-space\"><\/div>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-05.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-41765 size-full\" title=\"context.xml\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-05.jpg\" alt=\"context.xml\" width=\"1018\" height=\"569\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-05.jpg 1018w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-05-300x168.jpg 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-05-768x429.jpg 768w\" sizes=\"(max-width: 1018px) 100vw, 1018px\" \/><\/a><\/p>\n<h2 class=\"ack-h2\">In web.xml<\/h2>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-06.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-41764 size-full\" title=\"web.xml\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-06.jpg\" alt=\"web.xml\" width=\"1017\" height=\"567\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-06.jpg 1017w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-06-300x167.jpg 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-06-768x428.jpg 768w\" sizes=\"(max-width: 1017px) 100vw, 1017px\" \/><\/a><\/p>\n<div class=\"article-extra-space\"><\/div>\n<pre><code class=\"language-javascript\">\r\n&lt;resource-ref&gt;\r\n&lt;description&gt;MySQL Datasource example&lt;\/description&gt;\r\n&lt;res-ref-name&gt;jdbc\/jelasticDb&lt;\/res-ref-name&gt;\r\n&lt;res-type&gt;javax.sql.DataSource&lt;\/res-type&gt;\r\n&lt;res-auth&gt;Container&lt;\/res-auth&gt;\r\n&lt;\/resource-ref&gt;<\/code><\/pre>\n<div class=\"article-extra-space\"><\/div>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-41760 size-full\" title=\"Source Code Xml File\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047.jpg\" alt=\"Source Code Xml File\" width=\"1018\" height=\"570\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047.jpg 1018w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047-300x168.jpg 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-047-768x430.jpg 768w\" sizes=\"(max-width: 1018px) 100vw, 1018px\" \/><\/a><\/p>\n<p><strong>Step 5.<\/strong> Create a connection in a Java class file in the Root folder and save it with the .java extension (example myconnection.java).<\/p>\n<div class=\"article-space\"><\/div>\n<pre><code class=\"language-javascript\">\r\nimport java.sql.Connection;\r\nimport java.sql.SQLException;\r\nimport java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\nimport javax.naming.InitialContext;\r\nimport javax.naming.NamingException;\r\nimport javax.sql.DataSource;\r\npublic class MyConnection {\r\nprivate DataSource dataSource;\r\npublic MyConnection() {\r\ntry {\r\nInitialContext context = new InitialContext();\r\ndataSource = (DataSource) context.lookup(\"java:comp\/env\/jdbc\/accuweb_db\");\r\n} catch (NamingException ex) {\r\nLogger.getLogger(MyConnection.class.getName()).log(Level.SEVERE, null, ex);\r\n}\r\n}\r\npublic Connection getConnection() {\r\nConnection conn = null;\r\ntry {\r\nconn = dataSource.getConnection();\r\n} catch (SQLException ex) {\r\nLogger.getLogger(MyConnection.class.getName()).log(Level.SEVERE, null, ex);\r\n}\r\nreturn conn;\r\n}\r\n}<\/code><\/pre>\n<div class=\"article-extra-space\"><\/div>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-08.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-41763 size-full\" title=\"Web SSH\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-08.jpg\" alt=\"Web SSH\" width=\"894\" height=\"633\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-08.jpg 894w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-08-300x212.jpg 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-08-768x544.jpg 768w\" sizes=\"(max-width: 894px) 100vw, 894px\" \/><\/a><\/p>\n<p><strong>Step 6.<\/strong> After that, run the Java file using the command javac filename i.e. javac myconnection,java .<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-09.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-41762 size-full\" title=\"javac myconnection,java .\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-09.jpg\" alt=\"javac myconnection,java .\" width=\"907\" height=\"183\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-09.jpg 907w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-09-300x61.jpg 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-09-768x155.jpg 768w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/05\/Connection-to-DB-using-JNDI-09-900x183.jpg 900w\" sizes=\"(max-width: 907px) 100vw, 907px\" \/><\/a><\/p>\n<p>That&#8217;s it!<\/p>\n<h2 class=\"ack-h2\">Conclusion<\/h2>\n<p>In short, connecting to a database using JNDI has many advantages like making it easier to handle more users, keeping things secure, and making it simpler to set up. By using JNDI, developers can easily add database features to their apps without making the code too complicated.<\/p>\n<p>This method helps manage resources well and makes it easy to use the app in different situations. With proper setup and following good methods, JNDI is a dependable and effective way to connect databases in <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/application\/java-hosting\" target=\"_blank\" rel=\"noopener\">Java<\/a> apps.<\/p>\n<div class=\"cta-btn-top-space\"><\/div>\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t\n<div class=\"cta-btn-bottom-space\"><\/div>\n","protected":false},"author":1,"featured_media":52879,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","class_list":["post-41941","faq","type-faq","status-publish","has-post-thumbnail","hentry","faq_topics-connection-to-application","faq_topics-databases","faq_topics-java-connection","faq_topics-kb","faq_topics-mysql-mariadb-percona","faq_topics-product-documentation"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.10 (Yoast SEO v24.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JNDI Database Connection | AccuWeb.Cloud Guide<\/title>\n<meta name=\"description\" content=\"Learn how JNDI simplifies DB in Java. Follow our guide to seamlessly connect databases, enhance security, and optimize resource management.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Make a Connection to DB using JNDI?\" \/>\n<meta property=\"og:description\" content=\"Learn how JNDI simplifies DB in Java. Follow our guide to seamlessly connect databases, enhance security, and optimize resource management.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI\" \/>\n<meta property=\"og:site_name\" content=\"AccuWeb Cloud\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-19T05:12:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#article\",\"isPartOf\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-jndi\"},\"author\":{\"name\":\"Jilesh Patadiya\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58\"},\"headline\":\"How to Make a Connection to DB using JNDI?\",\"datePublished\":\"2024-05-22T12:00:11+00:00\",\"dateModified\":\"2026-02-19T05:12:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-jndi\"},\"wordCount\":360,\"publisher\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#primaryimage\"},\"thumbnailUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"inLanguage\":\"en-US\"},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-jndi\",\"url\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI\",\"name\":\"JNDI Database Connection | AccuWeb.Cloud Guide\",\"isPartOf\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#primaryimage\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#primaryimage\"},\"thumbnailUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"datePublished\":\"2024-05-22T12:00:11+00:00\",\"dateModified\":\"2026-02-19T05:12:46+00:00\",\"description\":\"Learn how JNDI simplifies DB in Java. Follow our guide to seamlessly connect databases, enhance security, and optimize resource management.\",\"breadcrumb\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#primaryimage\",\"url\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"contentUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/accuweb.cloud\/resource\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Make a Connection to DB using JNDI?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#website\",\"url\":\"https:\/\/accuweb.cloud\/resource\/\",\"name\":\"AccuWeb Cloud\",\"description\":\"Cutting Edge Cloud Computing\",\"publisher\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/accuweb.cloud\/resource\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\",\"name\":\"AccuWeb.Cloud\",\"url\":\"https:\/\/accuweb.cloud\/resource\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg\",\"contentUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg\",\"width\":156,\"height\":87,\"caption\":\"AccuWeb.Cloud\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58\",\"name\":\"Jilesh Patadiya\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g\",\"caption\":\"Jilesh Patadiya\"},\"description\":\"Jilesh Patadiya, the visionary Co-Founder and Chief Technology Officer (CTO) behind AccuWeb.Cloud. Founder &amp; CTO at AccuWebHosting.com. He shares his web hosting insights on the AccuWeb.Cloud blog. He mostly writes on the latest web hosting trends, WordPress, storage technologies, and Windows and Linux hosting platforms.\",\"sameAs\":[\"https:\/\/accuweb.cloud\/resource\",\"https:\/\/www.facebook.com\/accuwebhosting\",\"https:\/\/www.instagram.com\/accuwebhosting\/\",\"https:\/\/www.linkedin.com\/company\/accuwebhosting\/\",\"https:\/\/x.com\/accuwebhosting\",\"https:\/\/www.youtube.com\/c\/Accuwebhosting\"],\"url\":\"https:\/\/accuweb.cloud\/resource\/author\/accuwebadmin\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"JNDI Database Connection | AccuWeb.Cloud Guide","description":"Learn how JNDI simplifies DB in Java. Follow our guide to seamlessly connect databases, enhance security, and optimize resource management.","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:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI","og_locale":"en_US","og_type":"article","og_title":"How to Make a Connection to DB using JNDI?","og_description":"Learn how JNDI simplifies DB in Java. Follow our guide to seamlessly connect databases, enhance security, and optimize resource management.","og_url":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI","og_site_name":"AccuWeb Cloud","article_modified_time":"2026-02-19T05:12:46+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#article","isPartOf":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-jndi"},"author":{"name":"Jilesh Patadiya","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58"},"headline":"How to Make a Connection to DB using JNDI?","datePublished":"2024-05-22T12:00:11+00:00","dateModified":"2026-02-19T05:12:46+00:00","mainEntityOfPage":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-jndi"},"wordCount":360,"publisher":{"@id":"https:\/\/accuweb.cloud\/resource\/#organization"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#primaryimage"},"thumbnailUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","inLanguage":"en-US"},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-jndi","url":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI","name":"JNDI Database Connection | AccuWeb.Cloud Guide","isPartOf":{"@id":"https:\/\/accuweb.cloud\/resource\/#website"},"primaryImageOfPage":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#primaryimage"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#primaryimage"},"thumbnailUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","datePublished":"2024-05-22T12:00:11+00:00","dateModified":"2026-02-19T05:12:46+00:00","description":"Learn how JNDI simplifies DB in Java. Follow our guide to seamlessly connect databases, enhance security, and optimize resource management.","breadcrumb":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#primaryimage","url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","contentUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/accuweb.cloud\/resource\/articles\/database-connection-via-JNDI#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/accuweb.cloud\/resource\/"},{"@type":"ListItem","position":2,"name":"How to Make a Connection to DB using JNDI?"}]},{"@type":"WebSite","@id":"https:\/\/accuweb.cloud\/resource\/#website","url":"https:\/\/accuweb.cloud\/resource\/","name":"AccuWeb Cloud","description":"Cutting Edge Cloud Computing","publisher":{"@id":"https:\/\/accuweb.cloud\/resource\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/accuweb.cloud\/resource\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/accuweb.cloud\/resource\/#organization","name":"AccuWeb.Cloud","url":"https:\/\/accuweb.cloud\/resource\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/","url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg","contentUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg","width":156,"height":87,"caption":"AccuWeb.Cloud"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58","name":"Jilesh Patadiya","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g","caption":"Jilesh Patadiya"},"description":"Jilesh Patadiya, the visionary Co-Founder and Chief Technology Officer (CTO) behind AccuWeb.Cloud. Founder &amp; CTO at AccuWebHosting.com. He shares his web hosting insights on the AccuWeb.Cloud blog. He mostly writes on the latest web hosting trends, WordPress, storage technologies, and Windows and Linux hosting platforms.","sameAs":["https:\/\/accuweb.cloud\/resource","https:\/\/www.facebook.com\/accuwebhosting","https:\/\/www.instagram.com\/accuwebhosting\/","https:\/\/www.linkedin.com\/company\/accuwebhosting\/","https:\/\/x.com\/accuwebhosting","https:\/\/www.youtube.com\/c\/Accuwebhosting"],"url":"https:\/\/accuweb.cloud\/resource\/author\/accuwebadmin"}]}},"_links":{"self":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/41941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq"}],"about":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/types\/faq"}],"author":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/comments?post=41941"}],"version-history":[{"count":4,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/41941\/revisions"}],"predecessor-version":[{"id":53227,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/41941\/revisions\/53227"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/media\/52879"}],"wp:attachment":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/media?parent=41941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}