{"id":201,"date":"2007-09-06T00:00:00","date_gmt":"2007-09-06T00:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=201"},"modified":"2007-09-06T00:00:00","modified_gmt":"2007-09-06T00:00:00","slug":"Setting up MySQL Database and Tables","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=201","title":{"rendered":"Setting up MySQL Database and Tables"},"content":{"rendered":"<p><P>I am assuming that you have running instance of MySQL Database and you know how to work with the MySQL database. To access the database you should have valid user name and password.&nbsp;<\/P><br \/>\n<P>Let&#8217;s now start by creating the database for our struts- hibernate integration tutorial. Our application is very very simple and it searches for the keywords typed by user in the table. The database will contain one table &#8216;tutorials&#8217; for holding the tutorials links and descriptions. Here is the complete sql script for setting up the database.<\/P><br \/>\n<DIV align=left><br \/>\n<TABLE cellSpacing=0 cellPadding=0 width=\"80%\" bgColor=#ffff99 border=1><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TD width=\"100%\">&nbsp;<SPAN class=syntax><SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">CREATE<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">DATABASE<\/SPAN> <SPAN class=\"syntax_quote syntax_quote_backtick\">`struts-hibernate`<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_queryend\">;<\/SPAN><\/SPAN><br \/>\n<P><SPAN class=syntax><SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">CREATE<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">TABLE<\/SPAN> <SPAN class=\"syntax_quote syntax_quote_backtick\">`tutorials`<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_bracket_open_round\">(<\/SPAN><br \/>\n<DIV class=syntax_indent1><SPAN class=\"syntax_quote syntax_quote_backtick\">`id`<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_columnType\">INT<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">NOT<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">NULL<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">AUTO_INCREMENT<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_listsep\">,<\/SPAN><BR><SPAN class=\"syntax_quote syntax_quote_backtick\">`shortdesc`<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_columnType\">VARCHAR<\/SPAN><SPAN class=\"syntax_punct syntax_punct_bracket_open_round\">(<\/SPAN> <SPAN class=\"syntax_digit syntax_digit_integer\">50<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_bracket_close_round\">)<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">NOT<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">NULL<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_listsep\">,<\/SPAN><BR><SPAN class=\"syntax_quote syntax_quote_backtick\">`longdesc`<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_columnType\">VARCHAR<\/SPAN><SPAN class=\"syntax_punct syntax_punct_bracket_open_round\">(<\/SPAN> <SPAN class=\"syntax_digit syntax_digit_integer\">250<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_bracket_close_round\">)<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">NOT<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">NULL<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_listsep\">,<\/SPAN><BR><SPAN class=\"syntax_quote syntax_quote_backtick\">`pageurl`<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_columnType\">VARCHAR<\/SPAN><SPAN class=\"syntax_punct syntax_punct_bracket_open_round\">(<\/SPAN> <SPAN class=\"syntax_digit syntax_digit_integer\">100<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_bracket_close_round\">)<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">NOT<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">NULL<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_listsep\">,<\/SPAN><BR><SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">PRIMARY<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">KEY<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_bracket_open_round\">(<\/SPAN> <SPAN class=\"syntax_quote syntax_quote_backtick\">`id`<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_bracket_close_round\">)<\/SPAN> <\/DIV><SPAN class=\"syntax_punct syntax_punct_bracket_close_round\">)<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">TYPE<\/SPAN> <SPAN class=syntax_punct>=<\/SPAN> <SPAN class=\"syntax_alpha syntax_alpha_reservedWord\">MYISAM<\/SPAN> <SPAN class=\"syntax_punct syntax_punct_queryend\">;<\/SPAN><BR><\/SPAN><\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P>The above table holds the short description, long description and url of the tutorials. The field &#8216;<B>id<\/B>&#8216; is the unique identifier for records in the articles table.<\/P><br \/>\n<P>Here are the details of the each of the fields in the table:<\/P><br \/>\n<P><B>id:<\/B> Unique key for the table<\/P><br \/>\n<P><B>shortdesc:<\/B> This fields stores the short description of the tutorial.<\/P><br \/>\n<P><B>longdesc:<\/B> This field stores the full description about the tutorial<\/P><br \/>\n<P><B>pageurl:<\/B> This field is stores the url of the tutorial<\/P><br \/>\n<P>Run the following query to populate table with tutorials data:<\/P><br \/>\n<DIV align=left><br \/>\n<TABLE cellSpacing=0 cellPadding=0 width=\"80%\" bgColor=#ffff99 border=1><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TD width=\"100%\">INSERT INTO `tutorials` VALUES (1, &#8216;JSP Tutorials, Hibernate and struts Tutorials&#8217;, &#8216;This site contains many quality Java, JSP Tutorials, Hibernate Tutorials, Struts Tutorials, JSF Tutorials, RMI, MySQL Tutorials, Spring Tutorials, source codes and links to other java resources. We have large number of links to the tutorials on java&#8217;, &#8216;http:\/\/roseindia.net\/&#8217;);<br \/>\n<P><BR>INSERT INTO `tutorials` VALUES (2, &#8216;JSP Tutorial&#8217;, &#8216;Java Server Pages or JSP for short is Sun&#8221;s solution for developing dynamic web sites. JSP provide excellent server side scripting support for creating database driven web applications.&#8217;, &#8216;http:\/\/www.roseindia.net\/jsp\/jsp.shtml&#8217;);<\/P><br \/>\n<P><BR>INSERT INTO `tutorials` VALUES (3, &#8216;Struts Tutorials &#8211; Jakarta Struts Tutorial&#8217;, &#8216;This complete reference of Jakarta Struts shows you how to develop Struts applications using ant and deploy on the JBoss Application Server. Ant script is provided with the example code. Many advance topics like Tiles, Struts Validation Framework, Ja&#8217;, &#8216;http:\/\/www.roseindia.net\/struts\/index.shtml&#8217;);<\/P><br \/>\n<P><BR>INSERT INTO `tutorials` VALUES (4, &#8216;The Complete Spring Tutorial&#8217;, &#8216;Spring is grate framework for development of Enterprise grade applications. Spring is a light-weight framework for the development of enterprise-ready applications. Spring can be used to configure declarative transaction management, remote access to&#8217;, &#8216;http:\/\/www.roseindia.net\/spring\/index.shtml&#8217;);<\/P><br \/>\n<P><BR>INSERT INTO `tutorials` VALUES (5, &#8216;Java Server Faces (JSF) Tutorial&#8217;, &#8216;JavaServer Faces or JSF is grate technology for the development of user interfaces for web applications. The Java Server Faces specification is defined by JSR 127 of the Java Community Process.&#8217;, &#8216;http:\/\/www.roseindia.net\/jsf\/&#8217;);<\/P><br \/>\n<P><BR>INSERT INTO `tutorials` VALUES (6, &#8216;Jboss 3.0 Tutorial&#8217;, &#8216; This lesson shows you how to build you web application and install on the Jboss 3.0 application server. After the completion of this lesson you will be able to compile, assemble and deploy your J2EE application on Jboss 3.0 application server.&#8217;, &#8216;http:\/\/www.roseindia.net\/jboss\/index.shtml&#8217;);<BR><\/P><\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P>In the above steps we have setup our database. In the next section we will write java stuffs to integrate struts and hibernate.<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<DIV><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am assuming that you have running instance of MySQL Database and you know how to work with the MySQL database. To access the database you should have valid user name and password.&nbsp; Let&#8217;s now start by creating the database for our struts- hibernate integration tutorial. Our application is very very simple and it searches &hellip; <a href=\"https:\/\/www.strongd.net\/?p=201\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Setting up MySQL Database and Tables<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-201","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201"}],"version-history":[{"count":0,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}