{"id":187,"date":"2007-09-06T00:00:00","date_gmt":"2007-09-06T00:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=187"},"modified":"2007-09-06T00:00:00","modified_gmt":"2007-09-06T00:00:00","slug":"Configuring Struts DataSource Manager on Tomcat 5","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=187","title":{"rendered":"Configuring Struts DataSource Manager on Tomcat 5"},"content":{"rendered":"<p><P><FONT color=#000080>This tutorial shows you how you can configure Struts DataSource Manager on the Tomcat 5.5.9 server. We will use struts 1.2.7 in this tutorial. In this tutorial we will configure Struts DataSource Manager to use MySQL Database and use the connection provided by Struts DataSource in action class.<\/FONT><\/P><br \/>\n<P><B><FONT color=#000080>Downloading and Installing Tomcat 5.5.9<BR><\/FONT><\/B><FONT color=#000080>Download jakarta-tomcat-5.5.9 from <A href=\"http:\/\/jakarta.apache.org\/tomcat\/\">http:\/\/jakarta.apache.org\/tomcat\/<\/A>. Install it on your machine. Run and test the pages that comes with the tomcat.<\/FONT><\/P><br \/>\n<P><B><FONT color=#000080>Download Struts<BR><\/FONT><\/B><FONT color=#000080>Download Struts struts-1.2.7 from <A href=\"http:\/\/struts.apache.org\/download.cgi\">http:\/\/struts.apache.org\/download.cgi<\/A> and unzip it to your favorite directory. Go to the struts-1.2.7\\webapps directory and then unzip struts-blank.war file. We will use this file to write our tutorial.<\/FONT><\/P><br \/>\n<P><FONT color=#000080><B>Download MySQL JDBC Driver<\/B><BR>Download mysql-connector-java-3.0.16-ga-bin.jar from here <A href=\"http:\/\/www.roseindia.net\/struts\/mysql-connector-java-3.0.16-ga-bin.jar\">mysql-connector-java-3.0.16-ga-bin.jar<\/A> or you can download and use the latest version of mysql jdbc driver. Copy the JDBC driver file (mysql-connector-java-3.0.16-ga-bin.jar or latest version) to the <B>jakarta-tomcat-5.5.9\\common\\lib<\/B> directory of your tomcat installation. This will add the MySQL JDBC driver to the tomcat server.<\/FONT><\/P><br \/>\n<P><FONT color=#000080><B>Creating MySQL Database<\/B><BR>In this tutorial I am using MySQL server installed on my local machine. You can download and install MySQL on your local machine and use for this tutorial. If you already have MySQL server then you can use the existing MySQL server.<\/FONT><\/P><br \/>\n<P><FONT color=#000080>Create database &#8220;strutsdatabase&#8221; on the MySQL server and then run the following query to create test table.<\/FONT><\/P><br \/>\n<DIV align=left><br \/>\n<TABLE borderColor=#800000 cellSpacing=0 cellPadding=0 width=485 bgColor=#ffff66 border=1><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TD width=481>CREATE TABLE `test` (<BR>`username` varchar(20) NOT NULL default &#8221;<BR>) TYPE=MyISAM;<BR><BR>\/*Data for the table `test` *\/<BR><BR>insert into `test` values (&#8216;rajesh&#8217;),(&#8216;George&#8217;),(&#8216;Vikas&#8217;),(&#8216;Prakash&#8217;),(&#8216;Mahesh&#8217;);<BR><\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<DIV><br \/>\n<P><FONT color=#000080>Above query creates <B>test<\/B> table and then populates the table with data.<\/FONT><\/P><br \/>\n<P><FONT color=#000080><B>Configuring Struts Application<\/B><BR>Now create a directory &#8220;strutsdatabase&#8221; in the jakarta-tomcat-5.5.9\\webapps\\ directory and copy the content of struts-blank application (unzipped above) in the strutsdatabase directory.<\/FONT><\/P><br \/>\n<P><FONT color=#000080>Now start the tomcat and try to access the strutsdatabase application by typing the url <A href=\"http:\/\/localhost:8080\/strutsdatabase\">http:\/\/localhost:8080\/strutsdatabase<\/A> in browser. Your browser should display the welcome page. After testing shutdown the tomcat server.<\/FONT><\/P><br \/>\n<P><B><FONT color=#000080>Configuring Struts DataSource Manager<\/FONT><\/B><BR><FONT color=#000080>The Struts DataSource manager makes it easy for your Action class get the database connection. To configure the Stuts DataSource Manager we will uncomment the &lt;data-sources&gt; entry in the struts-config.xml.<\/FONT><\/P><br \/>\n<P><FONT color=#000080>Uncomment and then &lt;data-sources&gt; entry in the struts-config.xml and then change the line <\/FONT><\/P><br \/>\n<P><FONT color=#000080>&#8220;<B>org.apache.commons.dbcp.BasicDataSource<\/B>&#8221; to &#8220;<B>org.apache.tomcat.dbcp.dbcp.BasicDataSource<\/B>&#8220;. In tomcat 5.5.9 dbcp classes are packaged in <B>naming-factory-dbcp.jar<\/B> archieve, so we are using &#8220;org.apache.tomcat.dbcp.dbcp.BasicDataSource&#8221; instead of &#8220;org.apache.commons.dbcp.BasicDataSource&#8221;. After this change the database dirver, database url and passwor in the &lt;data-sources&gt; tag.<\/FONT><\/P><br \/>\n<P><FONT color=#000080>You &lt;data-source&gt; element should look like:<\/FONT><\/P><br \/>\n<DIV align=left><br \/>\n<TABLE borderColor=#800000 cellSpacing=0 cellPadding=0 width=639 bgColor=#ffff66 border=1><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TD width=635><PRE>&lt;data-sources&gt;<br \/>\n&lt;data-source type=&#8221;<B>org.apache.tomcat.dbcp.dbcp.BasicDataSource<\/B>&#8220;&gt;<br \/>\n    &lt;set-property<br \/>\n      property=&#8221;driverClassName&#8221;<br \/>\n      value=&#8221;com.mysql.jdbc.Driver&#8221; \/&gt;<br \/>\n    &lt;set-property<br \/>\n      property=&#8221;url&#8221;<br \/>\n      value=&#8221;jdbc:mysql:\/\/localhost:3306\/strutsdatabase?autoReconnect=true&#8221; \/&gt;<br \/>\n    &lt;set-property<br \/>\n      property=&#8221;username&#8221;<br \/>\n      value=&#8221;root&#8221; \/&gt;<br \/>\n    &lt;set-property<br \/>\n      property=&#8221;password&#8221;<br \/>\n      value=&#8221;&#8221; \/&gt;<br \/>\n    &lt;set-property<br \/>\n      property=&#8221;maxActive&#8221;<br \/>\n      value=&#8221;10&#8243; \/&gt;<br \/>\n    &lt;set-property<br \/>\n      property=&#8221;maxWait&#8221;<br \/>\n      value=&#8221;5000&#8243; \/&gt;<br \/>\n    &lt;set-property<br \/>\n      property=&#8221;defaultAutoCommit&#8221;<br \/>\n      value=&#8221;false&#8221; \/&gt;<br \/>\n    &lt;set-property<br \/>\n      property=&#8221;defaultReadOnly&#8221;<br \/>\n      value=&#8221;false&#8221; \/&gt;<br \/>\n    &lt;set-property<br \/>\n      property=&#8221;validationQuery&#8221;<br \/>\n      value=&#8221;SELECT COUNT(*) FROM test&#8221; \/&gt;<br \/>\n&lt;\/data-source&gt;<br \/>\n&lt;\/data-sources&gt;<br \/>\n        <\/PRE><\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P><FONT color=#000080><B>Create action Class to Test the DataSource<\/B><BR>Now we will write the code of Action class for getting the connection form DataSource:<BR><\/FONT><br \/>\n<DIV class=java align=left><br \/>\n<TABLE borderColor=#800000 cellSpacing=0 cellPadding=3 bgColor=#ffff66 border=1><br \/>\n<TBODY><br \/>\n<TR><!-- start source code --><br \/>\n<TD vAlign=top noWrap align=left><CODE><FONT color=#7f0055><B>package&nbsp;<\/B><\/FONT><FONT color=#000000>test;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>javax.servlet.http.HttpServletRequest;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>javax.servlet.http.HttpServletResponse;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.apache.struts.action.Action;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.apache.struts.action.ActionForm;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.apache.struts.action.ActionForward;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.apache.struts.action.ActionMapping;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>java.sql.*;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>public&nbsp;class&nbsp;<\/B><\/FONT><FONT color=#000000>TestDataSource&nbsp;<\/FONT><FONT color=#7f0055><B>extends&nbsp;<\/B><\/FONT><FONT color=#000000>Action<\/FONT><BR><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#000000>ActionForward&nbsp;execute<\/FONT><FONT color=#000000>(<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>ActionMapping&nbsp;mapping,<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>ActionForm&nbsp;form,<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>HttpServletRequest&nbsp;request,<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>HttpServletResponse&nbsp;response<\/FONT><FONT color=#000000>)&nbsp;<\/FONT><FONT color=#7f0055><B>throws&nbsp;<\/B><\/FONT><FONT color=#000000>Exception<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>javax.sql.DataSource&nbsp;dataSource;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>java.sql.Connection&nbsp;myConnection=<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>try&nbsp;<\/B><\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>dataSource&nbsp;=&nbsp;getDataSource<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>request<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>myConnection&nbsp;=&nbsp;dataSource.getConnection<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>Statement&nbsp;stmt=myConnection.createStatement<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>ResultSet&nbsp;rst=stmt.executeQuery<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;select&nbsp;username&nbsp;from&nbsp;test&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>System.out.println<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;******************************************&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>System.out.println<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;********Out&nbsp;Put&nbsp;from&nbsp;TestDataSource&nbsp;******&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>while<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>rst.next<\/FONT><FONT color=#000000>()){<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>System.out.println<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;User&nbsp;Name&nbsp;is:&nbsp;&#8221;&nbsp;<\/FONT><FONT color=#000000>+&nbsp;rst.getString<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;username&#8221;<\/FONT><FONT color=#000000>))<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>System.out.println<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;******************************************&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>rst.close<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>stmt.close<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/&nbsp;do&nbsp;what&nbsp;you&nbsp;wish&nbsp;with&nbsp;myConnection<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}&nbsp;<\/FONT><FONT color=#7f0055><B>catch&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>SQLException&nbsp;sqle<\/FONT><FONT color=#000000>)&nbsp;{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>getServlet<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>.log<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Connection.process&#8221;<\/FONT><FONT color=#000000>,&nbsp;sqle<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}&nbsp;<\/FONT><FONT color=#7f0055><B>finally&nbsp;<\/B><\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/enclose&nbsp;this&nbsp;in&nbsp;a&nbsp;finally&nbsp;block&nbsp;to&nbsp;make<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/sure&nbsp;the&nbsp;connection&nbsp;is&nbsp;closed<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>try&nbsp;<\/B><\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>myConnection.close<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}&nbsp;<\/FONT><FONT color=#7f0055><B>catch&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>SQLException&nbsp;e<\/FONT><FONT color=#000000>)&nbsp;{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>getServlet<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>.log<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Connection.close&#8221;<\/FONT><FONT color=#000000>,&nbsp;e<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>return&nbsp;<\/B><\/FONT><FONT color=#000000>mapping.findForward<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;success&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#000000>}&nbsp;<\/FONT><\/CODE> <\/TD><!-- end source code --><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P><FONT color=#000080>Following code is used to get the data source and then connection from Struts DataSource:<\/FONT><\/P><br \/>\n<P><FONT color=#0000ff>dataSource&nbsp;=&nbsp;getDataSource(request);<BR>myConnection&nbsp;=&nbsp;dataSource.getConnection();<\/FONT><FONT color=#000080><BR><\/FONT><\/P><br \/>\n<P><FONT color=#000080>Save this file(TestDataSource.java)&nbsp; into jakarta-tomcat-5.5.9\\webapps\\strutsdatabase\\WEB-INF\\src\\java\\test directory. Add the servlet API into class path. Then open dos prompt and navigate to jakarta-tomcat-5.5.9\\webapps\\strutsdatabase\\WEB-INF\\src\\ directory and issue run ant. This will compile the action class (TestDataSource.java) and copy it to the classes directory of the webapplication.<\/FONT><\/P><br \/>\n<P><FONT color=#000080><B>Creating Action Mapping struts-config.xml<\/B><BR>Now add the following action mapping into the struts-config.xml:<\/FONT><\/P><br \/>\n<DIV align=left><br \/>\n<TABLE borderColor=#800000 cellSpacing=0 cellPadding=0 width=400 bgColor=#ffff66 border=1><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TD>&lt;action<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; path=&#8221;\/DataSource&#8221;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type=&#8221;test.TestDataSource&#8221;&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;forward name=&#8221;success&#8221; path=&#8221;\/success.jsp&#8221;\/&gt;<BR>&lt;\/action&gt;<\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P><FONT color=#000080><B>Running and testing<\/B><BR>Start tomcat and browse the url <A href=\"http:\/\/localhost:8080\/strutsdatabase\/DataSource.do\">http:\/\/localhost:8080\/strutsdatabase\/DataSource.do<\/A>. Your browser should show the following output.<\/FONT><\/P><br \/>\n<P><IMG height=161 src=\"http:\/\/www.roseindia.net\/struts\/datasourceexample.gif\" width=526 border=1><\/P><br \/>\n<P><FONT color=#000080>Now check tomcat console, it should display records fetched from database.<BR><\/FONT><\/P><br \/>\n<P><FONT color=#000080>You can download my struts-config.xml from <A href=\"http:\/\/www.roseindia.net\/struts\/struts-config.xml\">here<\/A>.<\/FONT><\/P><br \/>\n<P><FONT color=#000080>Note: <STRONG>The DataSource manager is being retained in Struts 1.x for backward compatibility but may not be retained in Struts 2.x or later.<\/STRONG> <\/FONT><\/P><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows you how you can configure Struts DataSource Manager on the Tomcat 5.5.9 server. We will use struts 1.2.7 in this tutorial. In this tutorial we will configure Struts DataSource Manager to use MySQL Database and use the connection provided by Struts DataSource in action class. Downloading and Installing Tomcat 5.5.9Download jakarta-tomcat-5.5.9 from &hellip; <a href=\"https:\/\/www.strongd.net\/?p=187\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Configuring Struts DataSource Manager on Tomcat 5<\/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-187","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/187","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=187"}],"version-history":[{"count":0,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/187\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}