zoukankan      html  css  js  c++  java
  • 17_8_23 Spring Jdbc 英文数据库分词

    第一步:

    第二步:

    第三步:

    package dddd;
    
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import org.springframework.jdbc.core.JdbcTemplate;
    import org.springframework.jdbc.core.RowCallbackHandler;
    
    public class A {
    	public static void main(String[] args) {
    		ApplicationContext ac=new ClassPathXmlApplicationContext("classpath:kk.xml");
    		final JdbcTemplate jt=(JdbcTemplate)ac.getBean("jdbcTemplate");
    
    //		jt.query("select * from test", new RowCallbackHandler(){
    //			public void processRow(ResultSet rs) throws SQLException {
    //				String content=rs.getString(2);
    //				String[] contents=content.split("\W");     //本来一个表,分词:原来的table+分词table--->原来的id(在分词表中不是主键)
    //				for(String single:contents){
    //					String sqlinsert="insert test1(id,singleword) values(?,?)";
    //					Object[] args={rs.getInt(1),single};
    //					jt.update(sqlinsert,args);
    //				}
    //			}
    //		});
    
    		String sin="kk";
    		jt.query("select * from test where id in (select id from test1 where singleword='"+sin+"')", new RowCallbackHandler(){     //分词查询结果
    			public void processRow(ResultSet rs) throws SQLException {
    				System.out.println(rs.getInt("id")+".."+rs.getString(2));
    			}
    		});
    	}
    }
    
    
  • 相关阅读:
    字典的增删改查
    基础数据类型
    Linux程序优化实践
    Linuxt性能调优指南
    【MySQL】Percona Toolkits工具介绍及使用
    【MySQL】如何构建高性能MySQL系统?
    【MySQL】Event使用案例
    【MySQL】事件调度器 (Event Scheduler)
    【MySQL】mydumper工具介绍
    spu与sku的含义
  • 原文地址:https://www.cnblogs.com/du1991/p/7416242.html
Copyright © 2011-2022 走看看