java给文本文档进行分词处理_基于java对doc文档的分词,导入数据库

这篇博客展示了如何使用Java对doc文档进行分词处理,并将结果存储到数据库中。主要涉及的方法包括获取目录(getCatalogs),插入类型与目录(insert),插入上下文(insertContext)以及插入表格数据(insertSheet)。
摘要由CSDN通过智能技术生成

public ListgetCatalogs(){

List lists = new ArrayList<>();

Connection connection=Dbuitl.getConnection();

String sql= "select catalog from catalogs";

PreparedStatement preparedStatement= null;

ResultSet resultSet= null;try{

Statement statement=connection.createStatement();

resultSet=statement.executeQuery(sql);while(resultSet.next()) {

lists.add(resultSet.getString("catalog"));

}

}catch(SQLException e) {//TODO Auto-generated catch block

e.printStackTrace();

}finally{

Dbuitl.close(preparedStatement);

Dbuitl.close(connection);

}returnlists;

}public voidinsert(String type,String cata) {

Connection connection=Dbuitl.getConnection();

String sql= "insert into catalogs(type,catalog) value(?,?)";

PreparedStatement preparedStatement= null;

ResultSet resultSet= null;try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1, type);

preparedStatement.setString(2, cata);

preparedStatement.executeUpdate();

}catch(SQLException e) {//TODO Auto-generated catch block

e.printStackTrace();

}finally{

Dbuitl.close(preparedStatement);

Dbuitl.close(connection);

}

}public voidinsertContext(String catalog,String context) {

Connection connection=Dbuitl.getConnection();

String sql= "insert into context(catalog,context) value(?,?)";

PreparedStatement preparedStatement= null;

ResultSet resultSet= null;try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1, catalog);

preparedStatement.setString(2, context);

preparedStatement.executeUpdate();

}catch(SQLException e) {//TODO Auto-generated catch block

e.printStackTrace();

}finally{

Dbuitl.close(preparedStatement);

Dbuitl.close(connection);

}

}public voidinsertSheet(String sheet,String type) {

Connection connection=Dbuitl.getConnection();

String sql= "insert into sheet(sheet,type) value(?,?)";

PreparedStatement preparedStatement= null;

ResultSet resultSet= null;try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1, sheet);

preparedStatement.setString(2, type);

preparedStatement.executeUpdate();

}catch(SQLException e) {//TODO Auto-generated catch block

e.printStackTrace();

}finally{

Dbuitl.close(preparedStatement);

Dbuitl.close(connection);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值