Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding two queries to a table model
    text
    copied!<p>I have to add two queries to a table model so that it shows up on the table. It is a program doing prediction on soccer (EPL to be precise) and I need to display ALL results for the team when they are playing both home, and away. the first query is to get all the games where they play home, the second query is when they play away. Here is the code:</p> <pre><code>public void showResultsTotalTeam(){ deleteAllRows(dTableModel); // deleta all rows in the table try { conn = DriverManager.getConnection(connection.conn_url, connection.conn_user, connection.conn_pass);// connect to database server Statement sqlState = conn.createStatement();// create statement for sql String selectStuff = "SELECT games_team1, games_team2, games_winner, games_draw, games_team1_score, games_team2_score, games_month, games_day FROM games WHERE games_team1 = '" + cbxTeam1.getSelectedItem() + "'";// ststement for MySQL rows = sqlState.executeQuery(selectStuff); // execute statement String selectStuff2 = "SELECT games_team1, games_team2, games_winner, games_draw, games_team1_score, games_team2_score, games_month, games_day FROM games WHERE games_team2 = '" + cbxTeam1.getSelectedItem() + "'";// ststement for MySQL rows2 = sqlState.executeQuery(selectStuff); // execute statement Object[] tempRow;// create object array to store queried results Object[] tempRow2; while(rows.next()){ // while there are still values to be seen to tempRow = new Object[]{rows.getString(1), rows.getString(2), rows.getString(3), rows.getString(4), rows.getString(5), rows.getString(6), rows.getString(7), rows.getString(8)};// add data to array tempRow2 = new Object[]{rows2.getString(1), rows2.getString(2), rows2.getString(3), rows2.getString(4), rows2.getString(5), rows2.getString(6), rows2.getString(7), rows2.getString(8)}; dTableModel.addRow(tempRow); // add array to table model dTableModel.addRow(tempRow2); } } catch (SQLException ex) { // TODO Auto-generated catch block System.out.println(ex.getMessage()); } } </code></pre> <p>Now this code does not work and nothing shows up at all.</p> <p>Please help? Any advice would be great.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload