单元格内部无法识别Blob文件

时间:2018-12-08 10:45:04

标签: java mysql netbeans blob mysql-workbench

我一直在尝试在单元格上更精确地识别blob文件(pdf,单词),结果是con.mysql.cj.jdbc.Blob。如果有人可以帮助识别它并将其制成字符串,则单击该文件时将打开该文件。我不知道我的代码有什么问题。

 {
    Connection con = null;
    PreparedStatement pst = null;
    ResultSet rs = null;
    ArrayList<Project> projects = new ArrayList<Project>();
    initComponents();
    DefaultComboBoxModel dcbm = new DefaultComboBoxModel(new String[]{"Project Name", "Department"});
    ComboBoxF.setModel(dcbm);
    try {
        Class.forName("com.mysql.cj.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/gpms_DB?autoReconnect=true&useSSL=false" , "root" , "admin");
        String SQL = "SELECT * FROM `project`";
        pst = con.prepareStatement(SQL);
        rs = pst.executeQuery();
        while (rs.next()) {

            projects.add(new Project(rs.getInt("Project_id"), rs.getString("name"), rs.getDate("Submission_Date"),rs.getBlob("file"), rs.getString("Description"), rs.getInt("Doctors_id")));

        }
        DefaultTableModel model = new DefaultTableModel(0, rs.getMetaData().getColumnCount()){
        public boolean isCellEditable(int x , int y){
        return false;
        }
        };

        jTable2.setModel(model);
        model.setColumnIdentifiers(new String[]{"Project ID", "Project Name", "Submission Date","File", "Description", "Doctor ID"});
        Object[] row = new Object[6];
        for (int i = 0; i < projects.size(); i++) {
            row[0] = projects.get(i).getPid();
            row[1] = projects.get(i).getName();
            row[2] = projects.get(i).getSubmissionDate();
            row[3] = projects.get(i).getfile();
            row[4] = projects.get(i).getDescription();
            row[5] = projects.get(i).getDid();
            model.addRow(row);
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }
}

0 个答案:

没有答案