我想要做的是执行多个两个查询,并在jTable中显示结果。我尝试使用UNION,但表格中出现了奇怪的结果:
[B@58f67fc 3
[B@9f3d43e 1
[B@66f3378c 3
[B@69c3fd21 4
[B@421fb7c6 3
而不是实际的用户名
我已经看过了:mysql insert multi row query result into table?
这就是我使用的:
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection CC = DriverManager.getConnection("jdbc:mysql://localhost:3306/pulsedb", "root", "carrizo");
String getID = "SELECT stuff_id,med_specialty FROM mstuffinfo UNION ALL SELECT username,user_level FROM mstufflogin";
PreparedStatement PS = CC.prepareStatement(getID);
ResultSet RS = PS.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(RS));
}
catch(SQLException SQ)
{
SQ.printStackTrace();
SQ.getErrorCode();
}
catch (ClassNotFoundException ex) {
Logger.getLogger(PulseSTUFFLIST.class.getName()).log(Level.SEVERE, null, ex);
}
}