title: Running Hadoop DbCountPageView.java
body: <p>hi i am trying DbCountPageView examples given by Hadoop, first i run code simply without passing argument, it gives me some Database access pages information. After i tried to run this program giving arguements, but it gives me following error in eclipse:</p>
  
  <pre><code>Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database 'testdb,root,'
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.Util.getInstance(Util.java:386)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:928)
      at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1750)
      at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1290)
      at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2493)
      at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2526)
      at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)
      at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:834)
      at com.mysql.jdbc.JDBC4Connection.&lt;init&gt;(JDBC4Connection.java:47)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at org.apache.hadoop.examples.DBCountPageView.createConnection(DBCountPageView.java:102)
      at org.apache.hadoop.examples.DBCountPageView.initialize(DBCountPageView.java:131)
      at org.apache.hadoop.examples.DBCountPageView.run(DBCountPageView.java:394)
      at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
      at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
      at org.apache.hadoop.examples.DBCountPageView.main(DBCountPageView.java:432)
  </code></pre>
  
  <p>My arguements to the eclipse was "com.mysql.jdbc.Driver"  "jdbc:mysql://localhost:3306/testDb","root",""
  for mysql database. What is the error i dont know , it give me access denied error, i didnt put password to the mysql server. pls help.</p>
  
  <p>It is a large program avaliable in hadoop installation package in  :src-> examples->org/apache/ hadoop/example.</p>
  
  <p>The code where the arguement should pass is below</p>
  
  <pre><code>public int run(String[] args) throws Exception {
  
      String driverClassName = DRIVER_CLASS;
      String url = DB_URL;
  
      if(args.length &gt; 1) {
        driverClassName = args[0];
        url = args[1]+","+"root"+","+"";
      }
  
      initialize(driverClassName, url);
  
      JobConf job = new JobConf(getConf(), DBCountPageView.class);
  
      job.setJobName("Count Pageviews of URLs");
  
      job.setMapperClass(PageviewMapper.class);
      job.setCombinerClass(LongSumReducer.class);
      job.setReducerClass(PageviewReducer.class);
  
      DBConfiguration.configureDB(job, driverClassName, url);
  
      DBInputFormat.setInput(job, AccessRecord.class, "Access"
          , null, "url", AccessFieldNames);
  
      DBOutputFormat.setOutput(job, "Pageview", PageviewFieldNames);
  
      job.setMapOutputKeyClass(Text.class);
      job.setMapOutputValueClass(LongWritable.class);
  
      job.setOutputKeyClass(PageviewRecord.class);
      job.setOutputValueClass(NullWritable.class);
  
      try {
        JobClient.runJob(job);
  
        boolean correct = verify();
        if(!correct) {
          throw new RuntimeException("Evaluation was not correct!");
        }
      } finally {
        shutdown();    
      }
      return 0;
    }
  
    public static void main(String[] args) throws Exception {
  
      int ret = ToolRunner.run(new DBCountPageView(), args);
      System.exit(ret);
    }
  </code></pre>