欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql-请问:我这个代码怎修改,实现excel导入到MySQL中?谢谢

程序员文章站 2022-05-23 22:36:02
...
mysqlexcel数据库class

/**

  • 导入表时的选择器
  • @author yangenxiong
    *
    */
    class importTableChooser extends JFileChooser {

    private MainFrame mainFrame;

    private Database db;

    public importTableChooser(MainFrame mainFrame, Database db) {
    this.mainFrame = mainFrame;
    this.db = db;
    this.setFileSelectionMode(DIRECTORIES_ONLY);
    }

    public void approveSelection() {
    File file = this.getSelectedFile();
    if (file.isDirectory()) {
    //用户选择了目录
    File targetFile = new File(file.getAbsolutePath() + File.separator +
    this.db.getDatabaseName() + ".xls");
    this.mainFrame.importTable();
    } else {
    this.mainFrame.importTable();
    }
    super.approveSelection();
    }
    }