/** 
 * Project Name:nxfd2 
 * File Name:ApiEdos.java 
 * Package Name:com.hcks.cmfds.util 
 * Date:2016-7-25下午12:26:14 
 * Copyright (c) 2016, chenzhou1025@126.com All Rights Reserved. 
 * 
 */

package com.gyee.frame.util.taos;

import com.taosdata.jdbc.TSDBDriver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;


public class ApiTaos {

    private static Connection connection = null;

  
    private ApiTaos() {

    }

    public static Connection getInstance() throws Exception {
    	
    	

        if (connection == null) {
        	
        	connection = getConn();

        }

        return connection;

    }
    
    private static Connection getConn() throws Exception{
    	  Class.forName("com.taosdata.jdbc.TSDBDriver");
    	  // Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
    	  String jdbcUrl = "jdbc:TAOS://cm1:6030/test?user=root&password=taosdata";
    	  // String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata";
    	  Properties connProps = new Properties();
    	  connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
    	  connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
    	  connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
    	  Connection conn = DriverManager.getConnection(jdbcUrl, connProps);
    	  return conn;
    	}
}
