title: Accessing MS Access DB from web application
body: <p>I have been getting the below error while trying to access the table in MS Access DB.</p>
  
  <p>I have created the DB separately.</p>
  
  <p>Below is the code.</p>
  
  <pre><code>public String ValidateLogin(String un, String pw)
  {
      try
      {
  
          //  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              String url = "jdbc:ucanaccess://D:/questions1.accdb";
              Connection con = DriverManager.getConnection(url, "", "");
              Statement s =con.createStatement();
  
              String query="select count(*) from Users where UserName="+un;
              System.out.println(query);
              s.execute(query);
  
              ResultSet rs= s.getResultSet();
              if(rs==null)
              {
                  result="failure";
              }
              else
              {
                  String a1=rs.getString(3);
                  if(a1.equals(pw))
                  {
                      result="success";
                  }
                  else
                  {
                      result="failure";
                  }
              }
          }
          catch(Exception e)
          {
              e.printStackTrace();
          }
      return result;
  }
  </code></pre>
  
  <p>When I try to find the count of records, it is working fine. But when i try to fetch the records for one user, it is giving me the error.</p>
  
  <p>Please tell me what needs to be done.</p>
  
  <pre><code>net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::3.0.4 user lacks privilege or object not found: AAA
      at net.ucanaccess.jdbc.UcanaccessStatement.execute(UcanaccessStatement.java:154)
      at com.infy.dao.LoginActionDAO.ValidateLogin(LoginActionDAO.java:32)
      at com.infy.HelloWorldAction.execute(HelloWorldAction.java:33)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
      at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
      at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
      at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
      at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
      at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: AAA
      at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
      at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
      at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
      at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source)
      at net.ucanaccess.jdbc.Execute.executeWrapped(Execute.java:56)
      at net.ucanaccess.jdbc.AbstractExecute.executeBase(AbstractExecute.java:152)
      at net.ucanaccess.jdbc.Execute.execute(Execute.java:46)
      at net.ucanaccess.jdbc.UcanaccessStatement.execute(UcanaccessStatement.java:152)
      ... 66 more
  Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: AAA
      at org.hsqldb.error.Error.error(Unknown Source)
      at org.hsqldb.error.Error.error(Unknown Source)
      at org.hsqldb.ExpressionColumn.checkColumnsResolved(Unknown Source)
      at org.hsqldb.QueryExpression.resolve(Unknown Source)
      at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
      at org.hsqldb.ParserCommand.compilePart(Unknown Source)
      at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
      at org.hsqldb.Session.executeDirectStatement(Unknown Source)
      at org.hsqldb.Session.execute(Unknown Source)
      ... 72 more
  </code></pre>