真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

es-sql_jdbc鏈接查詢使用

package org.nlpcn.es4sql;

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、重慶小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了丁青免費(fèi)建站歡迎大家使用!

import com.alibaba.druid.pool.DruidDataSource;

import com.alibaba.druid.pool.ElasticSearchDruidDataSourceFactory;

import org.junit.Assert;

import org.junit.Test;

import java.math.BigDecimal;

import java.sql.*;

import java.util.ArrayList;

import java.util.Calendar;

import java.util.List;

import java.util.Properties;

/**

 * Created by allwefantasy on 8/26/16.

 */

public class JDBCTests {

    @Test

    public void testJDBC() throws Exception {

        Properties properties = new Properties();

        properties.put("url", "jdbc:elasticsearch://192.168.1.101:9300/" + TestsConstants.TEST_INDEX);

        DruidDataSource dds = (DruidDataSource) ElasticSearchDruidDataSourceFactory.createDataSource(properties);

        Connection connection = dds.getConnection();

        PreparedStatement ps = connection.prepareStatement("SELECT * from " + TestsConstants.TEST_INDEX + " where id='46091023'");

        

        Calendar Htime= Calendar.getInstance();

        double nowtime = Htime.getTime().getTime();

        

        ResultSet resultSet = ps.executeQuery();

        

        Calendar Ltime= Calendar.getInstance();

        double endtime = Ltime.getTime().getTime();

        BigDecimal longtime = new BigDecimal((endtime-nowtime)/1000);

        double second =longtime.setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue();

        

        List result = new ArrayList();

        while (resultSet.next()) {

            result.add(resultSet.getInt("id") + "," + resultSet.getString("age") + "," + resultSet.getString("name"));

        }

        System.out.println("查詢結(jié)果:"+result);

        System.out.println("耗時(shí):"+second+"秒");

        ps.close();

        connection.close();

        dds.close();

       

    }

}

package org.nlpcn.es4sql;

public class index {

public static void main(String[] args) {

// TODO Auto-generated method stub

gotop();

}

public static void gotop() {

JDBCTests server = new JDBCTests();

try {

server.testJDBC();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}


新聞名稱:es-sql_jdbc鏈接查詢使用
網(wǎng)頁網(wǎng)址:http://weahome.cn/article/ieeeig.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部