@william Thanks for your advice.

This is my source code to understand your reply.

import java.sql.*;
import java.util.*;

public class phoenixTest {
  public static void main(String args[]) throws Exception {
    Connection conn;
    //Properties prop = new Properties();
    Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
    long startTime = System.currentTimeMillis();
    conn =
 DriverManager.getConnection("jdbc:phoenix:localhost:2181:/hbase");
    long estimatedTime = System.currentTimeMillis() - startTime;
    System.out.format("got connection1 : %s ms\n",
Long.toString(estimatedTime));
    conn.close();

    startTime = System.currentTimeMillis();
    conn =
 DriverManager.getConnection("jdbc:phoenix:localhost:2181:/hbase");
    estimatedTime = System.currentTimeMillis() - startTime;
    System.out.format("got connection2 : %s ms\n",
Long.toString(estimatedTime));
    conn.close();


    startTime = System.currentTimeMillis();
    conn =
 DriverManager.getConnection("jdbc:phoenix:localhost:2181:/hbase");
    estimatedTime = System.currentTimeMillis() - startTime;
    System.out.format("got connection3 : %s ms\n",
Long.toString(estimatedTime));
    conn.close();
  }
}

Result
log4j:WARN No appenders could be found for logger
(org.apache.hadoop.conf.Configuration.deprecation).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.
got connection1 : 3431 ms
got connection2 : 0 ms
got connection3 : 1 ms

I'm re-writing my code as your advice.
It saved my time a lot.
Thanks again.

Reply via email to