{"id":1,"date":"2019-09-19T10:40:36","date_gmt":"2019-09-19T10:40:36","guid":{"rendered":"https:\/\/www.onlinenote.in\/hibernate\/?p=1"},"modified":"2019-09-19T10:52:24","modified_gmt":"2019-09-19T10:52:24","slug":"hibernate-example-configuration-file-hibernate-cfg-xml","status":"publish","type":"post","link":"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/","title":{"rendered":"Hibernate Example Configuration File \u2014 hibernate.cfg.xml"},"content":{"rendered":"<p>The configuration file contains information about the database and mapping file. Conventionally, its name should be <strong>hibernate.cfg.xml<\/strong>.<br \/>\ncreate an XML file named <strong>hibernate.cfg.xml<\/strong> under the resources folder<\/p>\n<pre class=\"lang:default decode:true \">&lt;!DOCTYPE hibernate-configuration PUBLIC\r\n        \"-\/\/Hibernate\/Hibernate Configuration DTD 3.0\/\/EN\"\r\n        \"http:\/\/www.hibernate.org\/dtd\/hibernate-configuration-3.0.dtd\"&gt;\r\n\r\n&lt;hibernate-configuration&gt;\r\n    &lt;session-factory&gt;\r\n\r\n        &lt;!-- JDBC Database connection settings --&gt;\r\n        &lt;property name=\"connection.driver_class\"&gt;com.mysql.cj.jdbc.Driver&lt;\/property&gt;\r\n        &lt;property name=\"connection.url\"&gt;jdbc:mysql:\/\/localhost:3306\/hibernate_db?useSSL=false&lt;\/property&gt;\r\n        &lt;property name=\"connection.username\"&gt;root&lt;\/property&gt;\r\n        &lt;property name=\"connection.password\"&gt;root&lt;\/property&gt;\r\n\r\n        &lt;!-- JDBC connection pool settings ... using built-in test pool --&gt;\r\n        &lt;property name=\"connection.pool_size\"&gt;1&lt;\/property&gt;\r\n\r\n        &lt;!-- Select our SQL dialect --&gt;\r\n        &lt;property name=\"dialect\"&gt;org.hibernate.dialect.MySQL5Dialect&lt;\/property&gt;\r\n\r\n        &lt;!-- Echo the SQL to stdout --&gt;\r\n        &lt;property name=\"show_sql\"&gt;true&lt;\/property&gt;\r\n\r\n        &lt;!-- Set the current session context --&gt;\r\n        &lt;property name=\"current_session_context_class\"&gt;thread&lt;\/property&gt;\r\n\r\n        &lt;!-- Drop and re-create the database schema on startup --&gt;\r\n        &lt;property name=\"hbm2ddl.auto\"&gt;create-drop&lt;\/property&gt;\r\n\r\n        &lt;!-- dbcp connection pool configuration --&gt;\r\n        &lt;property name=\"hibernate.dbcp.initialSize\"&gt;5&lt;\/property&gt;\r\n        &lt;property name=\"hibernate.dbcp.maxTotal\"&gt;20&lt;\/property&gt;\r\n        &lt;property name=\"hibernate.dbcp.maxIdle\"&gt;10&lt;\/property&gt;\r\n        &lt;property name=\"hibernate.dbcp.minIdle\"&gt;5&lt;\/property&gt;\r\n        &lt;property name=\"hibernate.dbcp.maxWaitMillis\"&gt;-1&lt;\/property&gt;\r\n        &lt;mapping class=\"net.javaguides.hibernate.entity.Student\" \/&gt;\r\n    &lt;\/session-factory&gt;\r\n&lt;\/hibernate-configuration&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The configuration file contains information about the database and mapping file. Conventionally, its name should be hibernate.cfg.xml. create an XML file named hibernate.cfg.xml under the resources folder &lt;!DOCTYPE hibernate-configuration PUBLIC &#8220;-\/\/Hibernate\/Hibernate Configuration DTD 3.0\/\/EN&#8221; &#8220;http:\/\/www.hibernate.org\/dtd\/hibernate-configuration-3.0.dtd&#8221;&gt; &lt;hibernate-configuration&gt; &lt;session-factory&gt; &lt;!&#8211; JDBC Database connection settings &#8211;&gt; &lt;property name=&#8221;connection.driver_class&#8221;&gt;com.mysql.cj.jdbc.Driver&lt;\/property&gt; &lt;property name=&#8221;connection.url&#8221;&gt;jdbc:mysql:\/\/localhost:3306\/hibernate_db?useSSL=false&lt;\/property&gt; &lt;property name=&#8221;connection.username&#8221;&gt;root&lt;\/property&gt; &lt;property name=&#8221;connection.password&#8221;&gt;root&lt;\/property&gt; &lt;!&#8211; JDBC connection pool [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.10 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hibernate Example Configuration File \u2014 hibernate.cfg.xml - Hibernate<\/title>\n<meta name=\"description\" content=\"The configuration file contains information about the database and mapping file. Conventionally, its name should be hibernate.cfg.xml\" \/>\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.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hibernate Example Configuration File \u2014 hibernate.cfg.xml - Hibernate\" \/>\n<meta property=\"og:description\" content=\"The configuration file contains information about the database and mapping file. Conventionally, its name should be hibernate.cfg.xml\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/\" \/>\n<meta property=\"og:site_name\" content=\"Hibernate\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-19T10:40:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-09-19T10:52:24+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/\",\"url\":\"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/\",\"name\":\"Hibernate Example Configuration File \u2014 hibernate.cfg.xml - Hibernate\",\"isPartOf\":{\"@id\":\"https:\/\/www.onlinenote.in\/hibernate\/#website\"},\"datePublished\":\"2019-09-19T10:40:36+00:00\",\"dateModified\":\"2019-09-19T10:52:24+00:00\",\"author\":{\"@id\":\"\"},\"description\":\"The configuration file contains information about the database and mapping file. Conventionally, its name should be hibernate.cfg.xml\",\"breadcrumb\":{\"@id\":\"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.onlinenote.in\/hibernate\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hibernate Example Configuration File \u2014 hibernate.cfg.xml\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.onlinenote.in\/hibernate\/#website\",\"url\":\"https:\/\/www.onlinenote.in\/hibernate\/\",\"name\":\"Hibernate\",\"description\":\"an object\u2013relational mapping tool for the Java programming language.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.onlinenote.in\/hibernate\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hibernate Example Configuration File \u2014 hibernate.cfg.xml - Hibernate","description":"The configuration file contains information about the database and mapping file. Conventionally, its name should be hibernate.cfg.xml","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.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/","og_locale":"en_US","og_type":"article","og_title":"Hibernate Example Configuration File \u2014 hibernate.cfg.xml - Hibernate","og_description":"The configuration file contains information about the database and mapping file. Conventionally, its name should be hibernate.cfg.xml","og_url":"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/","og_site_name":"Hibernate","article_published_time":"2019-09-19T10:40:36+00:00","article_modified_time":"2019-09-19T10:52:24+00:00","twitter_card":"summary_large_image","twitter_misc":{"Written by":"","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/","url":"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/","name":"Hibernate Example Configuration File \u2014 hibernate.cfg.xml - Hibernate","isPartOf":{"@id":"https:\/\/www.onlinenote.in\/hibernate\/#website"},"datePublished":"2019-09-19T10:40:36+00:00","dateModified":"2019-09-19T10:52:24+00:00","author":{"@id":""},"description":"The configuration file contains information about the database and mapping file. Conventionally, its name should be hibernate.cfg.xml","breadcrumb":{"@id":"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.onlinenote.in\/hibernate\/hibernate-example-configuration-file-hibernate-cfg-xml\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.onlinenote.in\/hibernate\/"},{"@type":"ListItem","position":2,"name":"Hibernate Example Configuration File \u2014 hibernate.cfg.xml"}]},{"@type":"WebSite","@id":"https:\/\/www.onlinenote.in\/hibernate\/#website","url":"https:\/\/www.onlinenote.in\/hibernate\/","name":"Hibernate","description":"an object\u2013relational mapping tool for the Java programming language.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.onlinenote.in\/hibernate\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":""}]}},"_links":{"self":[{"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":2,"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":5,"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/posts\/1\/revisions\/5"}],"wp:attachment":[{"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onlinenote.in\/hibernate\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}