<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5613102086291984388</id><updated>2011-07-30T16:47:49.897-07:00</updated><category term='linux'/><category term='flash'/><category term='form submit twice'/><category term='shell script'/><category term='lighttpd'/><category term='javascript'/><category term='mysql'/><category term='java'/><category term='clone hard disk'/><category term='database dump'/><category term='english'/><category term='rsync'/><category term='process'/><category term='jsp'/><category term='tomcat'/><category term='user authentication'/><category term='failover database'/><category term='compile'/><category term='UnsupportedClassVersionError'/><category term='postgreSQL'/><category term='logfiles'/><category term='logrotate'/><category term='movie'/><category term='synchronize'/><category term='compass cache'/><category term='terminal size'/><category term='Ruby'/><category term='boot priority'/><category term='session'/><category term='HTML'/><category term='script'/><category term='server'/><category term='exception'/><category term='Ubuntu'/><category term='Error'/><category term='Apache'/><category term='DD command'/><category term='architecture'/><category term='crontab'/><category term='replication'/><category term='sort'/><category term='load test'/><category term='database'/><category term='backup'/><title type='text'>JP</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>26</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-2872438869855954245</id><published>2009-12-06T00:54:00.000-08:00</published><updated>2009-12-06T02:07:40.351-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='compass cache'/><title type='text'>compass cache machanism in core  java</title><content type='html'>Compass is a powerful, transactional Java Search Engine framework. Now a days bean acting as important role in enterprise application. Compass allow us to map our bean to underlying search engine, sync data between compass index and datasource[persistence].&lt;br /&gt;&lt;br /&gt;I show you how we can make use of compass in core java. We can leverage this to advance level using hibernate and spring.&lt;br /&gt;&lt;br /&gt;1) Create java project &amp;amp; add compass jar to your lib.&lt;br /&gt;&lt;br /&gt;2) Create a bean called "User.java"&lt;br /&gt;&lt;br /&gt;User.java:&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&lt;br /&gt;@Searchable(alias="user")&lt;br /&gt;public class User {&lt;br /&gt;&lt;br /&gt;private Long id;&lt;br /&gt;private String name;&lt;br /&gt;private Integer yearsExperience;&lt;br /&gt;private Float income;&lt;br /&gt;&lt;br /&gt;public User() {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public User(Long id, String name, Integer yearsExperience, Float income) {&lt;br /&gt;  this.id = id;&lt;br /&gt;  this.name = name;&lt;br /&gt;  this.yearsExperience = yearsExperience;&lt;br /&gt;  this.income = income;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@SearchableId&lt;br /&gt;public Long getId() {&lt;br /&gt;  return id;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@SearchableProperty()&lt;br /&gt;public Float getIncome() {&lt;br /&gt;  return income;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@SearchableProperty()&lt;br /&gt;public String getName() {&lt;br /&gt;  return name;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@SearchableProperty()&lt;br /&gt;public Integer getYearsExperience() {&lt;br /&gt;  return yearsExperience;&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;@Searchable()&lt;/span&gt;&lt;/span&gt; annotation, tells to compass that User object to be indexed.&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;@SearchableId()&lt;/span&gt; annotation,  to mention unique id to refer the object.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;@SearchableProperty()&lt;/span&gt;&lt;/span&gt; annotation,  helps to what are the property to be index&lt;br /&gt;&lt;br /&gt;3) indexUser(Compass) method used to  index the user object.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;public static void index(Compass compass) {&lt;br /&gt;&lt;br /&gt;  CompassSession session = compass.openSession();&lt;br /&gt;&lt;br /&gt;  User user1 = new User(2l, "jp" , 100, 140000.0f);&lt;br /&gt;&lt;br /&gt;  CompassTransaction tx = session.beginTransaction();&lt;br /&gt;&lt;br /&gt;  session.save(user1);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  tx.commit();&lt;br /&gt;  session.close();&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This method cache the user1 object to memory.&lt;br /&gt;&lt;br /&gt;4) searchUser(Compass) method to search user1 object.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;public static void searchUser(Compass compass) {&lt;br /&gt;  CompassSession session = compass.openSession();&lt;br /&gt;  CompassTransaction tx = session.beginLocalTransaction();&lt;br /&gt;&lt;br /&gt;  CompassQueryBuilder cqb = session.queryBuilder();&lt;br /&gt;&lt;br /&gt;  CompassHits hits = cqb.bool()&lt;br /&gt;      .addMust(cqb.alias("user"))&lt;br /&gt;      .addMust(cqb.term("name", "jp"))&lt;br /&gt;      .toQuery().hits();&lt;br /&gt;&lt;br /&gt;  for(CompassHit hit : hits) {&lt;br /&gt;      User usr = (User)hit.data();&lt;br /&gt;      System.out.println(usr.getName()+"-"+usr.getYearsExperience+"-"+usr.getIncome);&lt;br /&gt;      System.out.println("hits="+hit.getScore());&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  tx.commit();&lt;br /&gt;  session.close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;we need to create compass session, transaction &amp;amp; query builder. Then get the hits from query builder.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;            &lt;span style="font-weight: bold;"&gt;.addMust(cqb.alias("user")&lt;/span&gt; line get the user object with help of alias. If we have relational bean this alias help us to search particular object like user, address, customer.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:100%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;5)  &lt;/span&gt;&lt;span style="font-size:100%;"&gt;Finally main() to index the user object and search&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:100%;" &gt; &lt;/span&gt;&lt;span style="font-size:100%;"&gt;the same&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public static void main( String[] args )  {&lt;br /&gt;   CompassConfiguration cfg = new CompassConfiguration();&lt;br /&gt;   cfg.configure();&lt;br /&gt;&lt;br /&gt;   Compass compass = cfg.buildCompass();&lt;br /&gt;&lt;br /&gt;   index(compass);&lt;br /&gt;   searchUser(compass);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:100%;"&gt;Output is &lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&lt;br /&gt;jp-100-140000.0&lt;br /&gt;hits= 1&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;Hits is 1, because our criteria matched for only one object.&lt;br /&gt;Here user1 object index to the memory and searched back from the same. As data grows we can't keep it in memory. In that case we can index objects to file system.&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-2872438869855954245?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/2872438869855954245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=2872438869855954245' title='37 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/2872438869855954245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/2872438869855954245'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2009/12/compass-cache-machanism-in-core-java.html' title='compass cache machanism in core  java'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>37</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-7447346476159369779</id><published>2009-12-03T01:53:00.000-08:00</published><updated>2009-12-03T02:04:56.817-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='form submit twice'/><title type='text'>javascript submitting form twice</title><content type='html'>&lt;p&gt;I have form with hidden fields. When i do change the country select box, taking the value of select box  &amp;amp; updating  the same in hidden field. When i hit the search button to search countries, i am submitting the form using javascript.&lt;/p&gt;&lt;p&gt;My code:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&amp;lt;a  href="#" onclick="submitMyForm();"&amp;gt;Search&amp;lt;/a&amp;gt;&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=5613102086291984388&amp;amp;postID=7447346476159369779#" onclick="submitMyForm();"&gt;&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;I was wondering this javascript submitted this form twice. First time with the value in the hidden box and second time with out.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;We found out the problem with my javascript code. &lt;/p&gt;&lt;p&gt;Correct code:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&amp;lt;a  href="#" onclick="submitMyForm();return false;"&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;&amp;gt;&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;Search&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;&amp;lt;&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;/a&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;&amp;gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;So "return false;" did trick for me.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Have fun&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-7447346476159369779?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/7447346476159369779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=7447346476159369779' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/7447346476159369779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/7447346476159369779'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2009/12/javascript-submitting-form-twice.html' title='javascript submitting form twice'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-2263714101872649835</id><published>2009-07-01T03:23:00.000-07:00</published><updated>2009-07-01T03:50:54.767-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tomcat'/><category scheme='http://www.blogger.com/atom/ns#' term='user authentication'/><title type='text'>Password protected application in tomcat server</title><content type='html'>We can do container level authentication in tomcat server. Tomcat support three types of authentication. DataSourceRealm, JDBCRealm, JNDIRealm, MemoryRealm.    &lt;a href="http://tomcat.apache.org/tomcat-5.5-doc/realm-howto.html" target="_blank"&gt;For more detail...&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;we will see implementation of "MemoryRealm". This uses XML file as the source to maintain the username and password.&lt;br /&gt;&lt;br /&gt;You can see &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;tomcat-home&gt;/conf/tomcat-users.xml&lt;/tomcat-home&gt;&lt;/span&gt;&lt;/span&gt; file contains the username, password and roles.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 1:&lt;/span&gt;&lt;br /&gt;You can add new user and roles as follows&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;?xml version='1.0' encoding='utf-8'?&amp;gt;&lt;br /&gt;&amp;lt;tomcat-users&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;role rolename="manager"/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;role rolename="admin"/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt; &amp;lt;role rolename="ananymous"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt; &amp;lt;user username="tomcat" password="tomcat" roles="manager,admin"/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;  &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt; &amp;lt;user username="newuser" password="password" roles="ananymous"/&amp;gt;&lt;br /&gt;&amp;lt;/tomcat-users&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 2:&lt;/span&gt;&lt;br /&gt;Next thing Enable MemoryRealm in the &lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;tomcat-home&amp;gt;/conf/server.xml&lt;/span&gt; file.&lt;br /&gt;By default UserDatabaseRealm is enabled. Comment out this and add the add the MemoryRealm &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&amp;lt;Realm className="org.apache.catalina.realm.MemoryRealm" /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 3:&lt;/span&gt;&lt;br /&gt;Have to add the security-constraint in our application's web.xml file. Assume that we have deployed "webapplication1" in tomcat[&amp;lt;tomcat-home&amp;gt;/webapp/webapplication1].&lt;br /&gt;We need to add following security-constraint in &lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;tomcat-home&amp;gt;/webapp/webapplication1/WEB-INF/web.xml. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;security-constraint&amp;gt;&lt;br /&gt;&amp;lt;web-resource-collection&amp;gt;&lt;br /&gt;&amp;lt;web-resource-name&amp;gt;Tomcat User authentication&amp;lt;/web-resource-name&amp;gt;&lt;br /&gt;&amp;lt;url-pattern&gt;/*&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;&amp;lt;/web-resource-collection&amp;gt;&lt;br /&gt;&amp;lt;auth-constraint&amp;gt;&lt;br /&gt;&amp;lt;role-name&amp;gt;anonymous&amp;lt;/role-name&amp;gt;&lt;br /&gt;&amp;lt;/auth-constraint&amp;gt;&lt;br /&gt;&amp;lt;/security-constraint&amp;gt;&lt;br /&gt;&amp;lt;login-config&amp;gt;&lt;br /&gt;&amp;lt;auth-method&amp;gt;BASIC&amp;lt;/auth-method&amp;gt;&lt;br /&gt;&amp;lt;realm-name&amp;gt;Tomcat User authentication&amp;lt;/realm-name&amp;gt;&lt;br /&gt;&amp;lt;/login-config&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;Role &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;role-name&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;anonymous&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;/role-name&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt; applied for all request comes to the webapplication1 for the url-pattern &lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;url-pattern&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;/*&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;/url-pattern&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;.&lt;br /&gt;&lt;br /&gt;If tomcat container encounter the security-constraint in the web.xml for the given request, it add the authentication header in the response. So broswer popups the window to receive username and password.&lt;br /&gt;&lt;br /&gt;IF username and password matches in the tomcat-users.xml, container allow the access the resource.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;auth-method&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;BASIC&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;/auth-method&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt; defines the authentication method to define the Realm. The possible values are BASIC, DIGEST and FORM.&lt;br /&gt;&lt;br /&gt;If our application uses some other security, tomcat MemoryRealm may give issues.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-2263714101872649835?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/2263714101872649835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=2263714101872649835' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/2263714101872649835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/2263714101872649835'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2009/07/password-protected-application-in.html' title='Password protected application in tomcat server'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-2838764562406486881</id><published>2009-06-18T00:02:00.000-07:00</published><updated>2009-06-18T00:31:02.062-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='boot priority'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>How to change OS boot priority in Ubuntu</title><content type='html'>Login as root user.&lt;br /&gt;edit the following file&lt;br /&gt;/boot/grub/mentu.lst&lt;br /&gt;&lt;br /&gt;you could see list of all installed OS here as follows:&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Note: I have installed Ubuntu and XP in my machine&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;title           &lt;/span&gt;&lt;span style="font-size:85%;"&gt;Ubuntu 8.10, kernel 2.6.27-7-generic&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;uuid            &lt;/span&gt;&lt;span style="font-size:85%;"&gt;1d034dd4-58c3-4ae9-abc0-c1b5e4591639&lt;br /&gt;kernel          /boot/vmlinuz-2.6.27-7-generic root=UUID=1d034dd4-58c3-4ae9-abc0-c1b5e4591639 ro quiet splash&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;initrd &lt;/span&gt;&lt;span style="font-size:85%;"&gt;         /boot/initrd.img-2.6.27-7-generic&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;&lt;br /&gt;title           &lt;/span&gt;&lt;span style="font-size:85%;"&gt;Ubuntu 8.10, kernel 2.6.27-7-generic (recovery mode)&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;uuid &lt;/span&gt;&lt;span style="font-size:85%;"&gt;       ....   &lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;kernel        &lt;/span&gt;&lt;span style="font-size:85%;"&gt;....&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;&lt;br /&gt;title           &lt;/span&gt;&lt;span style="font-size:85%;"&gt;Ubuntu 8.10, memtest86+&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;uuid &lt;/span&gt;&lt;span style="font-size:85%;"&gt;       ....   &lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;kernel        &lt;/span&gt;&lt;span style="font-size:85%;"&gt;....&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;&lt;br /&gt;title           &lt;/span&gt;&lt;span style="font-size:85%;"&gt;Other operating systems:&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;root &lt;/span&gt;&lt;span style="font-size:85%;"&gt;       ....&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;&lt;br /&gt;title           &lt;/span&gt;&lt;span style="font-size:85%;"&gt;Microsoft Windows XP Home Edition&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;root        &lt;/span&gt;&lt;span style="font-size:85%;"&gt;....&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The id start from 0.&lt;br /&gt;i.e.&lt;br /&gt;0 = Ubuntu 8.10, kernel 2.6.27-7-generic&lt;br /&gt;1 = Ubuntu 8.10, kernel 2.6.27-7-generic (recovery mode)&lt;br /&gt;2 = Ubuntu 8.10, memtest86+&lt;br /&gt;3 = Other operating systems:&lt;br /&gt;4 = Microsoft Windows XP Home Edition&lt;br /&gt;&lt;br /&gt;The following line is taking care of which OS to boot by default&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;default 0&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;this means by default Ubuntu 8.10, kernel 2.6.27-7-generic will be booted&lt;br /&gt;&lt;br /&gt;If we want to boot XP as default, change this line to&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;default 4&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;save the file. When you boot next time by default XP will be booted.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-2838764562406486881?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/2838764562406486881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=2838764562406486881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/2838764562406486881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/2838764562406486881'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2009/06/how-to-change-os-boot-priority-in.html' title='How to change OS boot priority in Ubuntu'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-3015868103788613833</id><published>2009-06-16T23:06:00.000-07:00</published><updated>2009-06-16T23:11:11.310-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='exception'/><category scheme='http://www.blogger.com/atom/ns#' term='UnsupportedClassVersionError'/><title type='text'>java UnsupportedClassVersionError</title><content type='html'>While deploy java code into tomcat, it thrown exception as follows&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;SEVERE: Exception starting filter struts&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class jcaptcha4struts2.core.actions.support.CaptchaImageResult)&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;        at org.apache.catalina.loader.WebappClassLoader.findClassInternal( WebappClassLoader.java:1851)&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;        at org.apache.catalina.loader.WebappClassLoader.findClass( WebappClassLoader.java:890)&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;.......&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;.......&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;17 Mar, 2009 1:29:25 PM org.apache.catalina.core.ApplicationContext log&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:85%;" &gt;INFO: Closing Spring root WebApplicationContext&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The problem is version conflict [development machine java version is 1.5 but machine where i deploy has the 1.6 version]&lt;br /&gt;&lt;br /&gt;To fix this problem we need to install java-1.6 version in the deployment machine.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-3015868103788613833?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/3015868103788613833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=3015868103788613833' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/3015868103788613833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/3015868103788613833'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2009/06/java-unsupportedclassversionerror.html' title='java UnsupportedClassVersionError'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-7935374098417947352</id><published>2009-06-15T04:32:00.000-07:00</published><updated>2009-06-15T04:45:09.329-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='form submit twice'/><category scheme='http://www.blogger.com/atom/ns#' term='jsp'/><title type='text'>JSP form getting submitted twice</title><content type='html'>When i was working in the struts2,hibernate and spring technology, strangely "null pointer exception" thrown for attribute which used in the form even i give valid input.&lt;br /&gt;&lt;br /&gt;I dig this issue and found that, struts action called twice when i request for the URL. Again this also crazy for me. When debug the application, found that browser sending new request if any empty 'src' in the &amp;lt;img&amp;gt; tag present in the code.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;code&lt;/span&gt;&lt;br /&gt;&amp;lt;img src=""&amp;gt;&lt;br /&gt;&lt;br /&gt;In our case browser sent second request with empty form[no data] . so obviously "null pointer exception".&lt;br /&gt;&lt;br /&gt;so take out or give the valid image src name and this will fix the problem.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-7935374098417947352?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/7935374098417947352/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=7935374098417947352' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/7935374098417947352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/7935374098417947352'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2009/06/jsp-form-getting-submitted-twice.html' title='JSP form getting submitted twice'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-276404766271587342</id><published>2008-11-07T00:27:00.000-08:00</published><updated>2008-11-07T00:40:15.115-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='flash'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><title type='text'>Embed flash in html using javascript</title><content type='html'>Now a days Web applications embedding flash or video to describe about the stuff. I was came across the scenario where i have to embed flash in my web application.&lt;br /&gt;&lt;br /&gt;I found that using javascript is better option.&lt;br /&gt;&lt;br /&gt;Find the complete code in the following URL.&lt;br /&gt;&lt;br /&gt;&lt;a id="publishedDocumentUrl" class="tabcontent" target="_blank" href="http://docs.google.com/Doc?id=dgbxv8m3_0f9znh9d9"&gt;http://docs.google.com/Doc?id=dgbxv8m3_0f9znh9d9&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This is plain HTML document. One thing you have to take care is source file path. In above URL's document, you could find ####### symbol inside of  the body tag.&lt;br /&gt;&lt;br /&gt;You have to just replace ####### with your flash file absolute path.&lt;br /&gt;for example... &lt;br /&gt;/home/JP/demo.swf is name of the flash file. ###### should be replace with /home/JP/demo&lt;br /&gt;&lt;br /&gt;Have fun.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-276404766271587342?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/276404766271587342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=276404766271587342' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/276404766271587342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/276404766271587342'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/11/embed-flash-in-html-using-javascript.html' title='Embed flash in html using javascript'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-4765043547268476703</id><published>2008-10-09T01:48:00.000-07:00</published><updated>2008-10-09T02:04:26.046-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='failover database'/><category scheme='http://www.blogger.com/atom/ns#' term='replication'/><title type='text'>mysql replication</title><content type='html'>&lt;span style="font-size:100%;"&gt;While working in application deployment you might have come across the term called "failover database". That means if any hardware problem in the DB server we can't access the database at all. So we have one  more DB server to manage the application. When DB1 have some problem we can manage using DB2.&lt;br /&gt;&lt;br /&gt;So to achieve this what i thought was have to take &lt;a href="http://jp-javaprogrammer.blogspot.com/search/label/database%20dump"&gt;mysqldump&lt;/a&gt; and import to second server periodically. But there is the better facility in mysql 5.x version called "mysql replication". But mysql 5.1.x is stable for mysql replication. What mysql replication doing is simply coping the mysql-bin log from source DB server to detination DB server. whenever we do any transaction that will be logged in mysql-bin log. So coping mysql-bin log from one machine to another is the soluction for failover database problem.&lt;br /&gt;&lt;br /&gt;For mysql replication just we need to change some configuration in my.cnf file.&lt;br /&gt;&lt;br /&gt;you can find this file using the following command&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;find . | grep my.cnf&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;i)&lt;/span&gt;&lt;span style="font-size:100%;"&gt; Edit the my.cnf file in server1[uncomment the line server-id = 1 by default commented]&lt;br /&gt;my.cnf&lt;br /&gt;======&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;server-id     = 1&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span&gt;ii)&lt;/span&gt; Edit the my.cnf file in server2 [Uncomment the following entries and give proper values]&lt;br /&gt;my.cnf&lt;br /&gt;==========&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;server-id       = 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;master-host     =   192.168.2.51&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;master-user     =  repl&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;master-password =  password&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;log-bin        =  mysql-bin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;explanation:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;master-host : DB server1 IP address.&lt;br /&gt;master-user : this user should have all privileges. While create this user use the follwoing command to grant permission.&lt;br /&gt;GRANT ALL PRIVILEGES ON *.* TO 'user'@'host'&lt;br /&gt;   IDENTIFIED BY 'some_pass';&lt;br /&gt;master-password: password of the master-user&lt;br /&gt;&lt;br /&gt;&lt;span&gt;iii)&lt;/span&gt; Restart the mysql server using the following command&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;/etc/init.d/mysql restart&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Whenever we do  data manipulation both server will have same data and in sync. Now failover database is ready. This is the way to do mysql replication.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-4765043547268476703?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/4765043547268476703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=4765043547268476703' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/4765043547268476703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/4765043547268476703'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/10/mysql-replication.html' title='mysql replication'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-4798874331350179330</id><published>2008-10-02T03:33:00.000-07:00</published><updated>2008-10-02T03:46:27.375-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='synchronize'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='rsync'/><title type='text'>Synchronize directories/files between servers</title><content type='html'>I came across the scenario where, we have to synchronize files and directories between different servers. For example[Refer image1] my application update images in server1 only. But the same image shoule be synchronized in server2 also.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_wLOMq_xcVv8/SOSj0-WumfI/AAAAAAAAATI/yIxsoz0ho2s/s1600-h/1.GIF"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://4.bp.blogspot.com/_wLOMq_xcVv8/SOSj0-WumfI/AAAAAAAAATI/yIxsoz0ho2s/s320/1.GIF" alt="" id="BLOGGER_PHOTO_ID_5252503195907693042" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;T&lt;span style="font-size:100%;"&gt;here is tool 'Rsync' for linux to acheive this scenario.&lt;br /&gt;Install Rsync in two servers. We are going to sync server1 with server2. So here destination server is server2.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In server2 add the following configration files.&lt;br /&gt;&lt;br /&gt;i) Create &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;rsync.conf&lt;/span&gt;&lt;/span&gt; file in /etc/rsync.conf&lt;br /&gt;Add the following code given in between two lines in this file.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;#############################&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;motd file = /etc/rsyncd.motd &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;log file = /var/log/rsyncd.log &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;pid file = /var/run/rsyncd.pid &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;lock file = /var/run/rsync.lock&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;[thumbnails]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;  path = /var/www/html/images&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;  comment = Image Server&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;  uid = apache&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;  gid = apache&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;  read only = no&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;  list = yes&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;#############################&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;Explanation:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;First four lines are log,pid,lock and motd files path&lt;br /&gt;&lt;br /&gt;[thumbnails] is the label. This will refered in server1 to send the directories to server2.&lt;br /&gt;path is the place where the directories and files will get stored.&lt;br /&gt;&lt;br /&gt;ii) Create &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;rsyncd.motd&lt;/span&gt;&lt;/span&gt; file in /ect/rsyncd.motd&lt;br /&gt;&lt;br /&gt;Add some text. This will shown at the time of sync.&lt;br /&gt;For expample add text like in between two lines.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;#############################&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;File transfering.........&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;#############################&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;iii) By default rsync is disabled. So we have to enable Rsync. You can edit the file &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;/etc/xinetd.d/rsync&lt;/span&gt; and chage the line as disable = no [by default disable = yes]&lt;br /&gt;&lt;br /&gt;iv) Start the rsync server&lt;br /&gt;&lt;/span&gt; &lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt; /etc/init.d/xinetd start&lt;/span&gt;&lt;br /&gt;Server2 [Destination server] configuration over.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;In server1, only one line command will sync the file or directories to server2.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;rsync -rptgou /absolute path/images 192.168.100.50::thumbnails&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Explanation:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;rsync ==&gt;&lt;/span&gt; is the command&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;-rptgou ===&gt;&lt;/span&gt;&lt;/span&gt; is the options&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;/absolute path/images  ===&gt;&lt;/span&gt;&lt;/span&gt; images is the directory we are going to transfer to server2&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;192.168.100.50::thumbnails ===&gt;&lt;/span&gt;&lt;/span&gt; this is the server2 ip and thumbnails is the lable we have added in "rsync.conf" configuration file in server2&lt;br /&gt;&lt;br /&gt;We can add the above command in crontab so that two servers in the sync.&lt;br /&gt;Enjoy........&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-4798874331350179330?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/4798874331350179330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=4798874331350179330' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/4798874331350179330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/4798874331350179330'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/10/synchronize-directoriesfiles-between.html' title='Synchronize directories/files between servers'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_wLOMq_xcVv8/SOSj0-WumfI/AAAAAAAAATI/yIxsoz0ho2s/s72-c/1.GIF' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-8553841479738544798</id><published>2008-09-29T21:52:00.000-07:00</published><updated>2008-09-29T22:39:43.791-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Error'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>MySql ERROR 1054</title><content type='html'>I was breaking my head when i was doing import data from mysqldump in Linux machine. The problem was &lt;span style="font-weight: bold;font-size:85%;" &gt;"ERROR 1054 (42S22) at line 1564: Unknown column 'cust.CUSTOMER_NAME' in 'field list' "&lt;/span&gt;. I surfed the net but i couldn't get any stuff.&lt;br /&gt;&lt;br /&gt;Then i put this problem on my guru[Mukund]. He explained the  problem.&lt;br /&gt;&lt;br /&gt;MySql behave as case-in-sensitive in microsoft environment. So while writing function, procedure and trigger case is no issues in microsoft environment. But in case of Linux, MySql behave as case-sensitive. All the development machines were Microsoft Environment. Production environment is Linux.&lt;br /&gt;&lt;br /&gt;To fix this problem [To make Linux case insensitive] add the following line in the file  /etc/mysql/my.cnf&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;lower_case_table_name = 1&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;This line make &lt;/span&gt;&lt;span style="font-size:100%;"&gt;MySql&lt;/span&gt;&lt;span style="font-size:100%;"&gt; case-in-sensitive in linux environment. &lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-8553841479738544798?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/8553841479738544798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=8553841479738544798' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/8553841479738544798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/8553841479738544798'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/09/mysql-error-1054.html' title='MySql ERROR 1054'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-3978867156618267784</id><published>2008-09-23T02:14:00.000-07:00</published><updated>2008-09-25T04:00:21.182-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><title type='text'>HTML Redirect to new URL</title><content type='html'>This is very useful when we want redirect from one page/site to other page/site.&lt;br /&gt;For example the following code written in &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;home.html&lt;/span&gt;&lt;/span&gt;. Whenever you clicked on this home.html link, browser will take you to &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;http://jp-javaprogrammer.blogspot.com&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;meta equiv="Content-Type" content="text/html; charset=iso-8859-1"&amp;gt;&lt;br /&gt;&amp;lt;meta equiv="REFRESH" content="0; URL=http://jp-javaprogrammer.blogspot.com/"&amp;gt;&lt;br /&gt;&amp;lt;title&gt;JP&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Here http-equiv="REFRESH" tag reload/redirect the page after the mentioned time in the content tag.&lt;br /&gt;Content=0 means immediately redirect /load the page.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-3978867156618267784?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/3978867156618267784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=3978867156618267784' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/3978867156618267784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/3978867156618267784'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/09/html-redirect-to-new-url.html' title='HTML Redirect to new URL'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-1206643870833698520</id><published>2008-09-19T04:08:00.000-07:00</published><updated>2008-09-25T03:59:25.387-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Error'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>Mysql Error : Mysql has gone away.</title><content type='html'>I had a problem while import database from my server to local around 117MB size. Suddenly i got in a problem. That was "Mysql has gone away". I surfed the net and got the solution.&lt;br /&gt;&lt;br /&gt;When mysql server receives packet more than mentioned in &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;max_allowed_packet&lt;/span&gt; &lt;/span&gt;in mysql server configuration&lt;span style="font-weight: bold;"&gt;,  &lt;/span&gt;mysql server  throw out the error "Mysql has gone away".&lt;br /&gt;&lt;br /&gt;To fix this problem you can change &lt;span style="font-weight: bold;font-size:85%;" &gt;max_allowed_packet&lt;/span&gt;  value in  &lt;span style="font-weight: bold;font-size:85%;" &gt;my.cnf&lt;/span&gt; file in linux machine. This file will be in /etc/mysql/my.cnf&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;max_allowed_packet      = 36M&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Restart mysql.&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-1206643870833698520?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/1206643870833698520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=1206643870833698520' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/1206643870833698520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/1206643870833698520'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/09/mysql-error-mysql-has-gone-away.html' title='Mysql Error : Mysql has gone away.'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-7241365188459651145</id><published>2008-09-18T05:26:00.000-07:00</published><updated>2008-09-25T04:01:41.454-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='shell script'/><title type='text'>How to Run Unix shell script in java</title><content type='html'>I came across the scenario wherein  i have to call/ Run the unix shell script. I think this would help you guys.&lt;br /&gt;&lt;br /&gt;I have written a script called custom_script.sh.&lt;br /&gt;&lt;br /&gt;custom_script.sh code:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;cp /home/Example.java /home/Example_copy.java&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In this script just i am copying a file to another.&lt;br /&gt;&lt;br /&gt;The java code to call that script.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;import java.io.BufferedWriter;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;import java.io.*;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;public class CallScript&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;{&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;       public static void main(String s[]) throws Exception{&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;       Runtime rt = Runtime.getRuntime();               &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;           try {&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;                    String str = "/absolute_path/test.sh";&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;                    Process child = rt.exec("/bin/bash");&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;                    BufferedWriter outCommand = new BufferedWriter(new Output&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;StreamWriter(child.getOutputStream()));&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;                    outCommand.write(str +"\n");&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;                    outCommand.flush();&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;  &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;               } catch (Exception e) {&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;                                       e.printStackTrace();&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;                   }&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;}&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:arial;font-size:85%;"  &gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-7241365188459651145?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/7241365188459651145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=7241365188459651145' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/7241365188459651145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/7241365188459651145'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/09/how-to-run-unixshell-script-in-java.html' title='How to Run Unix shell script in java'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-2694312305965165287</id><published>2008-08-25T21:58:00.000-07:00</published><updated>2008-09-25T04:07:13.615-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='load test'/><category scheme='http://www.blogger.com/atom/ns#' term='Apache'/><title type='text'>Apache load test tool</title><content type='html'>For web application, to test server load is important one to check the performance.&lt;br /&gt;&lt;br /&gt;If you have installed apache in your machine, you could use "ab"[apache benchmarking] command to test the server load.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;command:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;ab -n 100 -c 100 http://abc.com/&lt;br /&gt;&lt;br /&gt;Explanation:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;ab ---&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt; &lt;/span&gt;&lt;span style="font-style: italic;"&gt;apache command&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;-n ---&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt; &lt;/span&gt;&lt;span style="font-style: italic;"&gt;number of requests&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;-c ---&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt; &lt;/span&gt;&lt;span style="font-style: italic;"&gt;number of concurrent requests.&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;for &lt;a href="http://httpd.apache.org/docs/2.0/programs/ab.html"&gt;more&lt;/a&gt; info&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-2694312305965165287?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/2694312305965165287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=2694312305965165287' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/2694312305965165287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/2694312305965165287'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/08/apaches-server-load-test-tool.html' title='Apache load test tool'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-6013872302455979406</id><published>2008-08-20T22:13:00.000-07:00</published><updated>2008-09-25T04:07:54.174-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><category scheme='http://www.blogger.com/atom/ns#' term='terminal size'/><title type='text'>How to change default size of terminal [Ubuntu]</title><content type='html'>You can edit the following file with root access.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;/usr/share/vte/termcap/xterm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The following entry is the one we have to change.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;:co#80:it#8:li#24:\&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;To change the number of columns, change the co# number, in this case 80.&lt;br /&gt;To change the number of rows, change the li# number, in this case 24.&lt;br /&gt;So as an example if you want a terminal window of 80x54:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;:co#80:it#8:li#54:\&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Now the terminal size would be half of the screen.&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-6013872302455979406?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/6013872302455979406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=6013872302455979406' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/6013872302455979406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/6013872302455979406'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/08/how-to-change-default-size-of-ubuntu.html' title='How to change default size of terminal [Ubuntu]'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-6826033647299255533</id><published>2008-07-31T03:19:00.000-07:00</published><updated>2008-09-25T04:10:37.705-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DD command'/><category scheme='http://www.blogger.com/atom/ns#' term='clone hard disk'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>clone hard disk in linux</title><content type='html'>Install all software for development machine is tedious job. Just think of a team of 5 or above. Linux offer DD command to reduce this job as much as easier.&lt;br /&gt;What we could do with the help of DD command is, just install all the software in one machine and clone that hard disk to other hard disks. Here the constraints is hard disks[source and destination] should be same size.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Step 1:&lt;/span&gt;&lt;br /&gt;Install all softwares you want.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Step 2:&lt;/span&gt;&lt;br /&gt;Connect the second hard disk to machine where in all software has been installed.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Stop 3:&lt;/span&gt;&lt;br /&gt;Mount command list all the media connected in that machine.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Stop 4:&lt;/span&gt;&lt;br /&gt;Now you have find out in which hard disk you have already installed all software.&lt;br /&gt;Now two hard disk connected to your machine.&lt;br /&gt;but you can view only one hard disk unless you mount another one. To confirm which media is source and which media is destination, You have to mount.&lt;br /&gt;While run DD command we have to give the name of the media namely sda or sdb etc... So we have to confirm the media name.&lt;br /&gt;To mount&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;i)&lt;/span&gt; Make a directory in /media. For ex /media/hd&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;ii)&lt;/span&gt; &lt;/span&gt;run a follwoing command to mount media to a directory.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;    mount /dev/sda7 /media/hd&lt;/span&gt;&lt;br /&gt;/dev directory will contains all media details.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;iii)&lt;/span&gt; after confirmation of which media is source[for ex sdb] and which media is destination[for ex sda] have to unmount the device using the following command.&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;umount /media/hd&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;step 5:&lt;/span&gt;&lt;br /&gt;finally you have to run the following command to clone the hard disk from one to another with root user.&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;dd if=/dev/sdb of=/dev/sda&lt;br /&gt;Explanation:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;dd =&gt; disk to disk command&lt;br /&gt;if =&gt; input file&lt;br /&gt;of =&gt; output file&lt;br /&gt;&lt;br /&gt;This will take an hour to copy. You could do the same stuff for any number of machines within an hour per machine.&lt;br /&gt;Enjoy maadi.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-6826033647299255533?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/6826033647299255533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=6826033647299255533' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/6826033647299255533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/6826033647299255533'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/07/clone-hard-disk-in-linux.html' title='clone hard disk in linux'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-1444019084115297635</id><published>2008-07-08T22:28:00.000-07:00</published><updated>2008-09-25T04:11:36.843-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='process'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='sort'/><title type='text'>Sort process by memory</title><content type='html'>The following command help to sort list of process running in linux machine.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;ps -eo pmem,pid,args | sort -k 1 -n -r | less&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Explanation:&lt;/span&gt;&lt;br /&gt;pmem -&gt; list the memory occupied by the process&lt;br /&gt;pid     -&gt; process ID&lt;br /&gt;args   -&gt; process&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-1444019084115297635?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/1444019084115297635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=1444019084115297635' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/1444019084115297635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/1444019084115297635'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/07/sort-process-by-memory.html' title='Sort process by memory'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-8160558189110489919</id><published>2008-06-20T00:39:00.000-07:00</published><updated>2008-09-25T04:12:39.284-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='database dump'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='postgreSQL'/><title type='text'>database dump for mysql and postgreSQL</title><content type='html'>User's data is very very important. Obviously most of application stores user data in the database.&lt;br /&gt;&lt;br /&gt;Database backup is mandatory those who are use user data in their application.&lt;br /&gt;&lt;br /&gt;If something happen to database, using dump we can restore the backup to the database.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;MySql database:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;To dump/export:&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;mysqldump --user {username} --password {password} {database}  backup.sql&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;br /&gt;mysqldump is the command to dump/export the database to file.&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;To undump/import:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;mysql --user {username} --password {password} {database}&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;This will extract backup.sql to the database&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;PostgreSQL database:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;To dump/export:&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;pg_dump -h {host-name} -U {username} -p {database name}  backup.sql&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span&gt;Explanation:&lt;br /&gt;pg_dump is the command to dump the database. The above command dump all data in the database {database} to the backup.sql file.&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;To undump/import:&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;psql -h {host-name} -U {username} -p&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt; {database name} &amp;lt; backup.sql&lt;span&gt;&lt;span style="font-weight: bold;"&gt; &lt;database.sql&gt;&lt;/database.sql&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Dump/Export postgreSQL database:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Same as mysql this command will import data from backup.sql to the database.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-8160558189110489919?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/8160558189110489919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=8160558189110489919' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/8160558189110489919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/8160558189110489919'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/06/database-dump-mysql-and-postgresql.html' title='database dump for mysql and postgreSQL'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-3467238683148532194</id><published>2008-06-09T22:48:00.001-07:00</published><updated>2008-09-25T04:14:01.142-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='server'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='lighttpd'/><category scheme='http://www.blogger.com/atom/ns#' term='compile'/><title type='text'>compile lighttpd server from source</title><content type='html'>To install any server like 'lighttpd' for windows operating system we can download and install using  .exe file.&lt;br /&gt;Same way we could do it for other operating system [sun solaris, linux and mac]also. But for some specific distribution there won't be any executable version of software.&lt;br /&gt;&lt;br /&gt;In this case, we can compile from source code and install the same.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;I explained installation steps in the ubuntu[linux distribution] server.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Login as root.&lt;br /&gt;&lt;br /&gt;There is two way to download the source code&lt;br /&gt;&lt;br /&gt;1) Using terminal:&lt;br /&gt;Copy the url of the software which we want to install. That might be any kind of compressed format. for ex:[tar.gz,tar.bz2,etc...] and use the following command&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;wget {URL}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;this will downloads source code using terminal.&lt;br /&gt;or&lt;br /&gt;2) Using GUI&lt;br /&gt;Click on download link and save to local file system.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;Steps to compile and install:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;i) Uncompress the file which one we downloaded. Using the following command in terminal&lt;br /&gt;  if downloaded file is .tar.gz format use &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;tar -xzvf {downloaded file name}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  if downloaded file is .tar.bz2 use &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;tar -xjvf {downloaded file name}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ii) Get inside the folder and there is file named &lt;span style="font-weight: bold;"&gt;"configure"&lt;/span&gt; and type the following command&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;./configure&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;if we want install in any specific directory, mention directory using the following command.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;./configure --prefix = {directory}&lt;/span&gt;&lt;span style="font-size:85%;"&gt;....&lt;/span&gt; [default installation directory is &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;/opt/&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;]&lt;br /&gt;The above command will configure the compilation environment.&lt;br /&gt;&lt;br /&gt;iii) Type the following to compile&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;make&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;now source code compiled.&lt;br /&gt;&lt;br /&gt;iv) To install&lt;br /&gt;  &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;make install&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Now server is installed and ready for you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-3467238683148532194?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/3467238683148532194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=3467238683148532194' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/3467238683148532194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/3467238683148532194'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/06/compile-lighttpd-server-from-source.html' title='compile lighttpd server from source'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-871642231872956169</id><published>2008-05-25T03:18:00.000-07:00</published><updated>2008-09-25T04:14:40.177-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='architecture'/><title type='text'>J2EE vs Ruby</title><content type='html'>&lt;span style="font-weight: bold;font-size:85%;" &gt;Rails and a typical J2EE Web stack&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Rails stack to a typical J2EE Web stack comprised of the Tomcat servlet container, the Struts Web application framework, and the Hibernate persistence framework.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_wLOMq_xcVv8/SDk9Uvwxq4I/AAAAAAAAACI/ldr7vVL5fR0/s1600-h/stack.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_wLOMq_xcVv8/SDk9Uvwxq4I/AAAAAAAAACI/ldr7vVL5fR0/s320/stack.jpg" alt="" id="BLOGGER_PHOTO_ID_5204258271031044994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Comparison of Rails and J2EE stacks&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As you can see, the fundamental difference between the Rails stack and the components that make up a common J2EE-based Web application is small. Both have a container in which the application code will execute; an MVC framework that helps to separate the application's model, view, and control; and a mechanism to persist data.&lt;a target="_blank" href="http://www-128.ibm.com/developerworks/web/library/wa-rubyonrails/"&gt;&lt;span style="font-weight: bold;"&gt;Reference&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-871642231872956169?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/871642231872956169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=871642231872956169' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/871642231872956169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/871642231872956169'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/05/rails-and-typical-j2ee-web-stack-rails.html' title='J2EE vs Ruby'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_wLOMq_xcVv8/SDk9Uvwxq4I/AAAAAAAAACI/ldr7vVL5fR0/s72-c/stack.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-6928911854646883904</id><published>2008-05-07T05:38:00.000-07:00</published><updated>2008-09-25T04:15:31.406-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>Mysql create user, database &amp; access</title><content type='html'>I broken my head to create user and give access permission to the particular database.&lt;br /&gt;&lt;br /&gt;Finally i got the problem that "Version problem".&lt;br /&gt;&lt;br /&gt;I am using &lt;span style="font-size:85%;"&gt;"&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;mysql  Ver 14.7 Distrib 4.1.20, for redhat-linux-gnu (i686)&lt;/span&gt;&lt;span style="font-size:85%;"&gt;"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you face this problem then, this post will help you reduce your time.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Commands:&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;1) CREATE DATABASE {DATABASE NAME};&lt;br /&gt;2) GRANT ALL PRIVILEGES ON {DATABASE_NAME}.* TO '{USER NAME}'@'host' IDENTIFIED BY 'password';&lt;br /&gt;3) use mysql;&lt;br /&gt;4) update user set select_priv = 'Y',update_priv = 'Y',create_priv = 'Y', delete_priv = 'Y' where user = 'USER_NAME';&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Explanation:&lt;/span&gt;&lt;br /&gt;1) &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;CREATE DATABASE &lt;/span&gt;&lt;database name=""&gt;&lt;span style="font-size:85%;"&gt;;&lt;/span&gt;&lt;/database&gt;&lt;/span&gt;&lt;br /&gt;  Create database.&lt;br /&gt;2) &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;GRANT ALL PRIVILEGES ON DATABASE_NAME.* TO '&lt;/span&gt;&lt;user name=""&gt;&lt;span style="font-size:85%;"&gt;'@'host' IDENTIFIED BY 'password';&lt;/span&gt;&lt;/user&gt;&lt;/span&gt;&lt;br /&gt;  We haven't created user but granting permission to the user. This will create a user with name {USER_NAME} in the "user" table of "mysql" database.&lt;br /&gt;3) &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;use mysql;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  Login to mysql table to update the table level permission.&lt;br /&gt;4) &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;update user set select_priv = 'Y',update_priv = 'Y',create_priv = 'Y', delete_priv = 'Y' where    user = 'USER_NAME';&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  This will update the basic manipulation permission to the user.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-6928911854646883904?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/6928911854646883904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=6928911854646883904' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/6928911854646883904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/6928911854646883904'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/05/mysql-create-user-database-access.html' title='Mysql create user, database &amp; access'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-5635708350944069241</id><published>2008-04-20T01:04:00.000-07:00</published><updated>2008-09-25T04:16:22.911-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='session'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>clear session files - Ruby</title><content type='html'>Session is important for web application as track user. Session grow likely same as log files. This will cause memory overhead. We can clear session using Linux crontab command.&lt;br /&gt;&lt;br /&gt;This will remove 300 minutes old session files by every day 00:10 hrs.&lt;br /&gt;&lt;br /&gt;Place this command in the crontab file in the /usr/bin/ directroy.&lt;br /&gt;&lt;br /&gt;Can edit the crontab file using following command.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;crontab -e&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;* * * * * find absolute_path -name 'sess.*' -amin +300 -exec rm -rf {} \;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Explanation:&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;10 0 * * * find /home/tmp -name 'ruby_sess.*' -amin +300 -exec rm -rf {} \;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;find&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;- find the file  that start with the name sess.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;br /&gt;min +300&lt;/span&gt; - find the session file with 300 minutes old&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;exec rm -rf&lt;/span&gt; - execute the command remove the files which is 300 minutes old.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-5635708350944069241?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/5635708350944069241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=5635708350944069241' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/5635708350944069241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/5635708350944069241'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/04/clear-session-files.html' title='clear session files - Ruby'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-17296399710438051</id><published>2008-04-16T02:47:00.000-07:00</published><updated>2008-09-25T04:18:09.391-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='logrotate'/><category scheme='http://www.blogger.com/atom/ns#' term='logfiles'/><title type='text'>Rotate log files</title><content type='html'>Logging is come into picture when something went wrong in application and have to point out the root cause of the problem.&lt;br /&gt;&lt;br /&gt;Some times application running out of disk space. This is not because of our code but because of log files generated by apps.&lt;br /&gt;&lt;br /&gt;Logrotate is effective utility for manage files which grow rapidliy like catalina.out and etc....&lt;br /&gt;&lt;br /&gt;To rotate ghe old log files we can use log4j in java ,log4r in Ruby. There is another cool way to Rotate the log in unix based servers.&lt;br /&gt;&lt;br /&gt;There is a configuration file called logrotate.conf in /etc directory. Add the following code&lt;br /&gt;&lt;br /&gt;# Rotate MyApps logs&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;span style="font-weight: bold;"&gt;1) /home/MyApps/log/*.log {&lt;br /&gt;2)daily&lt;br /&gt;3) missingok&lt;br /&gt;4)rotate 5&lt;br /&gt;5)compress&lt;br /&gt;6)delaycompress&lt;br /&gt;7)notifempty&lt;br /&gt;8)copytruncate&lt;br /&gt;9)create 0666 devgroup devgroup&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;This will take care of log file to rotate.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Explanation:&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt; 1) /home/MyApps/log/*.log {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Absolute path to log file of project&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;2)daily&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;rotate log files daily&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;3) missingok&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;If log file is missing dont raise any error.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;4)rotate 5&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Log files rotated &lt;5&gt; times&lt;br /&gt;for Example the directory /log look like:&lt;br /&gt;production.log&lt;br /&gt;production.log.1&lt;br /&gt;produciton.log.2.gz&lt;br /&gt;produciton.log.3.gz&lt;br /&gt;production.log.4.gz&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt; 5)compress&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Old rotated file compressed to by default gzip&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;6)delaycompress&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;postpone compression of previous log file to next rotate&lt;br /&gt;current log would be production.log and previous log would be&lt;br /&gt;production.log.1 not production.log.1.gz&lt;br /&gt;for Example the directory /log look like:&lt;br /&gt;production.log&lt;br /&gt;production.log.1&lt;br /&gt;produciton.log.2.gz&lt;br /&gt;produciton.log.3.gz&lt;br /&gt;production.log.4.gz&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;7)notifempty&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;don't rotate if log file is empty&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;8)copytruncate&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Truncate  the  original log file in place after creating a copy,   instead of moving the old log file and optionally creating a new one.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;9)create 0666 devgroup devgroup&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;The file permission, user and group name of the rotated files&lt;br /&gt;file permission====&gt; 0666&lt;br /&gt;username      =====&gt; devgroup&lt;br /&gt;groupname     =====&gt; devgroup&lt;br /&gt;&lt;br /&gt;Go and start play with logrotate.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-17296399710438051?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/17296399710438051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=17296399710438051' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/17296399710438051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/17296399710438051'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/04/rotate-log-files.html' title='Rotate log files'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-8786203345340077409</id><published>2008-04-07T01:31:00.000-07:00</published><updated>2008-09-25T04:20:01.152-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='backup'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><category scheme='http://www.blogger.com/atom/ns#' term='crontab'/><title type='text'>Database backup script</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;b&gt;The script to take a backup of postgres database &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Steps:&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Step i)&lt;/span&gt;&lt;/span&gt; Write a shell script to dump the database.&lt;br /&gt;Create a .sh file using vi editor inside the /bin as follows...&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;vi /bin/backup-script.sh&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;1) #!/bin/bash&lt;br /&gt;2) BACKUP_DIR="/home/MyApps/regular_backup"&lt;br /&gt;3) PGHOST="192.168.100.167"&lt;br /&gt;4) PGUSER="postgres"&lt;br /&gt;5) /usr/bin/pg_dumpall -h $PGHOST -U $PGUSER | gzip &gt; $BACKUP_DIR/backup.gz&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Explanation:&lt;/span&gt;&lt;br /&gt;The first line &lt;span style="font-weight: bold;font-size:85%;" &gt;#!/bin/bash&lt;/span&gt; is just a declaration that this is a BASH script.&lt;br /&gt;&lt;br /&gt;2) &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;BACKUP_DIR="/home/MyApps/regular_backup"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;This line tells the target folder where our .gz file to be stored&lt;br /&gt;&lt;br /&gt;3) &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;PGHOST="192.168.100.167"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;4) &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;PGUSER="postgres"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Host IP where our postgres database is running and user name. If some other database have to add password .&lt;br /&gt;&lt;br /&gt;5)&lt;span style="font-weight: bold;font-size:85%;" &gt; /usr/bin/pg_dump -h $PGHOST -U $PGUSER | gzip &gt; $BACKUP_DIR/backup.gz&lt;/span&gt;&lt;br /&gt;This key statement is dump the database using command[/usr/bin/pg_dumpall] and user name and password[-h $PGHOST -U $PGUSER] and zip it up using gzip and target file backup.gz&lt;br /&gt;&lt;br /&gt;after saved this file should the file permission to 755&lt;br /&gt; &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;chmod 755 /bin/backup-script.sh&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Step ii)&lt;/span&gt; Add this script to &lt;a href="http://www.tutorial5.com/content/view/95/51/" target="_blank"&gt;&lt;span style="font-weight: bold;"&gt;crontab&lt;/span&gt;&lt;/a&gt; &lt;span style="font-style: italic;"&gt;[Crontab (CRON TABle)is a program that manipulates the CRON daemon]&lt;/span&gt; and configure time to run script.&lt;br /&gt;&lt;br /&gt;1) Edit crontab file in the directory &lt;span style="font-weight: bold;font-size:85%;" &gt;/usr/bin/crontab&lt;/span&gt; file using &lt;span style="font-style: italic;"&gt;crontab -e&lt;/span&gt; -e for edit/add entry in the crontab file.&lt;br /&gt;&lt;br /&gt;2) Add this line in crontab file&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;span style="font-weight: bold;"&gt;10 0 * * * /bin/backup-script.sh &gt;/dev/null 2&gt;&amp;amp;1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This crontab run the script /bin/backup-script.sh on the time frame.&lt;br /&gt;&lt;br /&gt;10 0 * * * is 10 minute 0 hours of every day every month end every year run the script which we have created in step 1[/bin/backup-script.sh]&lt;br /&gt;&lt;br /&gt;Your script is ready and will run and backup the database everyday morning 00:10&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-8786203345340077409?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/8786203345340077409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=8786203345340077409' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/8786203345340077409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/8786203345340077409'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/04/database-backup-script.html' title='Database backup script'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-3656929581185452319</id><published>2008-04-06T01:07:00.000-07:00</published><updated>2008-04-06T01:12:18.818-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>Online  Video download</title><content type='html'>One of the &lt;a href="http://dibosmovie.blogspot.com/"&gt; place&lt;/a&gt; to surf online English films&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-3656929581185452319?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/3656929581185452319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=3656929581185452319' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/3656929581185452319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/3656929581185452319'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/04/online-video-download.html' title='Online  Video download'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613102086291984388.post-8340083821192079704</id><published>2008-03-23T05:53:00.000-07:00</published><updated>2008-03-23T05:58:04.511-07:00</updated><title type='text'>CAPTCHA</title><content type='html'>The term &lt;a href="http://recaptcha.net/captcha.html" target="_blank"&gt;CAPTCHA &lt;/a&gt;(for Completely Automated Turing Test To Tell Computers and Humans Apart) was coined in 2000 by Luis von Ahn, Manuel Blum, Nicholas Hopper and John Langford of Carnegie Mellon University. At the time, they developed the first CAPTCHA to be used by Yahoo.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613102086291984388-8340083821192079704?l=jp-javaprogrammer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jp-javaprogrammer.blogspot.com/feeds/8340083821192079704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5613102086291984388&amp;postID=8340083821192079704' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/8340083821192079704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613102086291984388/posts/default/8340083821192079704'/><link rel='alternate' type='text/html' href='http://jp-javaprogrammer.blogspot.com/2008/03/captcha.html' title='CAPTCHA'/><author><name>JP</name><uri>http://www.blogger.com/profile/04005214919985634679</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_wLOMq_xcVv8/SxT30zIxTsI/AAAAAAAAAek/uZi9RzPnKZo/S220/jp1-blog-blue1.jpg'/></author><thr:total>0</thr:total></entry></feed>
