我写了这段代码,当软件启动时,它从数据库(MYSQL 控制中心)获取数据并将它们带到一个表中。但是当我编译这段代码时,会出现 2 个错误。
Note: C:\Users\Commander Shepard\Documents\NetBeansProjects\Furniture Management System\src\furnituremanagementsystem\employee.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
我的代码:
public class employee extends javax.swing.JFrame {
// Creates new form employee
public employee() {
initComponents();
Date now = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
datelabel.setText(formatter.format(now));
try {
Statement s = DB.getConnection().createStatement();
DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
dtm.setRowCount(0);
ResultSet r = s.executeQuery("SELECT * from Employee");
while (r.next()) {
Vector v = new Vector();
v.add(r.getString(1));
v.add(r.getString(2));
v.add(r.getString(3));
v.add(r.getString(4));
v.add(r.getString(5));
v.add(r.getString(6));
v.add(r.getString(7));
v.add(r.getString(8));
v.add(r.getString(9));
v.add(r.getString(10));
v.add(r.getString(11));
v.add(r.getString(12));
v.add(r.getString(13));
v.add(r.getString(14));
dtm.addRow(v);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings("unchecked")
...
}
这件事实际上并没有影响程序,它工作正常,但我想知道这是否会成为未来的问题,以及我是否应该对此采取措施。