title: Code working in Localhost but it dosent work in online website in java using hibernate
body: <p>I had made one web application in Java using frameworks -struts 2.0, hibernate 3.0, and tiles 2.0 . 
  and in my local system i am using JDK 1.6, apache- tomcat 6.0 and my SQL 5.5
  when i registering the user it works OK in my local system on my local-host.
  But when i registering on <a href="http://www.shreerajinvestment.com/Home/registration.jsp" rel="noreferrer">http://www.shreerajinvestment.com/Home/registration.jsp</a> its not working properly.</p>
  
  <p>what i have to do...?</p>
  
  <p><strong>In Online redirected on error action. But in local-host redirected on success action recored added successfully and registered.</strong> </p>
  
  <p><strong>struts code</strong></p>
  
  <pre><code>&lt;action name="registration" class="Registration" &gt;
  
      &lt;result name="input" &gt;/registration.jsp&lt;/result&gt;
      &lt;result name="error" &gt;/error.jsp&lt;/result&gt;
      &lt;result name="success" type="tiles" &gt;home&lt;/result&gt;
  &lt;/action&gt;
  </code></pre>
  
  <p>This is <strong>hibernateConfiguration.xml</strong> file</p>
  
  <pre><code> &lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
  
      &lt;property name="connection.useUnicode" &gt;true&lt;/property&gt;
      &lt;property name="connection.characterEncoding" &gt;UTF-8&lt;/property&gt;
      &lt;property name="connection.driver_class" &gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="connection.url" &gt;jdbc:mysql://mysiteIP:3306/databasename&lt;/property&gt; 
      &lt;property name="connection.username" &gt;root&lt;/property&gt;
      &lt;property name="connection.password" &gt;admin&lt;/property&gt;
      &lt;property name="dialect" &gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
      &lt;property name="current_session_context_class" &gt;thread&lt;/property&gt;
      &lt;property name="hibernate.transaction.factory_class" &gt;org.hibernate.transaction.JDBCTransactionFactory&lt;/property&gt;
  
      &lt;mapping resource="pojo/registrationpojo.hbm.xml" /&gt;
      &lt;mapping resource="pojo/lifepojo.hbm.xml" /&gt;
      &lt;mapping resource="pojo/gipojo.hbm.xml" /&gt;
      &lt;mapping resource="pojo/mfpojo.hbm.xml" /&gt;
      &lt;mapping resource="pojo/cdpojo.hbm.xml" /&gt;
      &lt;mapping resource="pojo/fdpojo.hbm.xml" /&gt;
  
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is <strong>registration.java</strong> file</p>
  
  <pre><code>package SRI.User;
  
  import java.util.Date;
  import java.util.List;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import org.apache.struts2.interceptor.ServletRequestAware;
  import org.hibernate.Session;
  import org.hibernate.Transaction;
  import pojo.RegistrationPojo;
  import admin.Common;
  import admin.HibernateUtils;
  import com.opensymphony.xwork2.ActionSupport;
  
  public class Registration extends ActionSupport implements ServletRequestAware
  {
  private static final long serialVersionUID = 1L;
  private HttpServletRequest myrequest = null;
  public List&lt;Registration&gt; regpojo = null;
  
  public HttpServletRequest getMyrequest() {
      return myrequest;
  }
  public void setMyrequest(HttpServletRequest myrequest) {
      this.myrequest = myrequest;
  }
  public List&lt;Registration&gt; getRegpojo() {
      return regpojo;
  }
  public void setRegpojo(List&lt;Registration&gt; regpojo) {
      this.regpojo = regpojo;
  }
  
  public String getFirst_name() {
      return first_name;
  }
  public void setFirst_name(String firstName) {
      first_name = firstName;
  }
  public Date getDob() {
      return dob;
  }
  public void setDob(Date dob) {
      this.dob = dob;
  }
      //other fields getter - seter
  
  private String first_name = null;
  private Date dob = null;
      //other fields
  
  private int flag;
  private String re = null;
  private Common mCommon = new Common(); 
  
  @SuppressWarnings("unchecked")
  public String execute() throws Exception
  {
      try
      {
          Session session = HibernateUtils.getSession();
          Transaction tx = session.beginTransaction();
  
          regpojo = session.createQuery("select m.uname from RegistrationPojo m").list();
  
          if(regpojo.size() == 0)
          {
              //code to add record in the table
              RegistrationPojo p1=new RegistrationPojo();
              p1.setFirst_name(getFirst_name());
              p1.setDob(mCommon.ChangeDateformat(getDob()));
              //set other fields 
              session.save(p1);
              tx.commit();
  
              System.out.println("Registration Successfully");
              re=SUCCESS;
          }
          else
          {
              for(int i=0; i&lt;regpojo.size(); i++)
              {
                  if(username.equals(regpojo.get(i)))
                  {
                      flag = 1;
                      break;
                  }
                  else
                  {
                      flag = 0;
                  }
              }
              if(flag == 0)
              {
  
                      //code to add record in the table
                      RegistrationPojo p1=new RegistrationPojo();
                      p1.setFirst_name(getFirst_name());
                      p1.setDob(mCommon.ChangeDateformat(getDob()));
                      //set other fields 
                      session.save(p1);
                      tx.commit();                
  
                                      System.out.println("Registration Successfully");
                  re=SUCCESS;
              }
              else
              {
                  System.out.println("ERROR");
                  addFieldError("un", "User Name is not Available");
                  re=INPUT;   
              }
          }
          HttpSession s=myrequest.getSession(true);
          s.setAttribute("uname",username);
          s.setAttribute("pwd",password);
  
      }
      catch(Exception ex)
      {
          re = ERROR;
          System.out.println("Connection Failed: "+ex);
          ex.printStackTrace();
      }
      return re;
  }
  
  public void setServletRequest(HttpServletRequest request) 
  {
      this.myrequest=request;
  }
  }
  </code></pre>
  
  <p>This is <strong>error log on web server</strong> file</p>
  
  <pre><code>Connection Failed: org.hibernate.exception.GenericJDBCException: Cannot open connection
  org.hibernate.exception.GenericJDBCException: Cannot open connection
  at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
  at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
  at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
  at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
  at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420)
  at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
  at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
  at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
  at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
  at SRI.User.Registration.execute(Registration.java:155)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601)
  at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:399)
  at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:262)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:224)
  at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:213)
  at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
  at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
  at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.ParametersInterceptor.intercept(ParametersInterceptor.java:161)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.PrepareInterceptor.intercept(PrepareInterceptor.java:115)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
  at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
  at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
  at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
  at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:507)
  at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:207)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
  at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
  at java.lang.Thread.run(Thread.java:722)
  Caused by: java.sql.SQLException: Access denied for user 'shreeraj_root'@'209.59.190.236' (using password: YES)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:798)
  at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3700)
  at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1203)
  at com.mysql.jdbc.Connection.createNewIO(Connection.java:2572)
  at com.mysql.jdbc.Connection.(Connection.java:1485)
  at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
  at java.sql.DriverManager.getConnection(DriverManager.java:579)
  at java.sql.DriverManager.getConnection(DriverManager.java:190)
  at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
  at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
  ... 119 more
  </code></pre>