Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As far as securing your database, I'd recommend creating a locked down user that can only execute stored procedures - then you don't have to worry about someone decompiling your code. They'd only be able to access what they can access through your code. <a href="http://www.webdeveloper.com/forum/showthread.php?t=232496" rel="nofollow">Here's a tutorial</a> on how to do that.</p> <p>As far as your main question goes, I would recommend all your data gathering/sorting be done in your SQL query. If you're doing that in the <code>JTable</code>, you end up mixing your Model and View (see <a href="http://www.webdeveloper.com/forum/showthread.php?t=232496" rel="nofollow">MVC</a> for more detail).</p> <p>So essentailly you want your data coming back from the query in this form:</p> <p><code>Student; Student Name; Test Assignment; Secondary Test Assignment</code></p> <p>Which means, </p> <ol> <li>You need to add a relation between your grade table and your assignment table (most likely addding <code>aid</code> to the <code>grading</code> table)</li> <li><p>You're going to need to come up with a slightly more complicated SQL Query - something like this:</p> <p><code>Select g.sid, g.name, a.name from ASSIGNMENTS a join GRADING g on a.aid = g.aid where g.tid = 123123 order by g.name</code></p></li> <li><p>Create a 2D array based on the data and put it in the table (If you're still using your PHP interface, you'll want to split the strings on your delimiters to create a 2D array.) </p> <p><code>((DefaultTableModel)table.getModel).setDataVector(data, columnNames);</code></p></li> </ol> <p><strong>EDIT</strong> If you're convinced you just want to search through the rows for a value, and then update a column in the row you found - this should get you in the right direction:</p> <pre><code>Integer searchStudentID = 123123; int searchColumn = 0; String updateValue = "Value"; int updateColumn = 3; //Look through the table for the right row Vector&lt;Vector&lt;Object&gt;&gt; data = ((DefaultTableModel)table.getModel()).getDataVector(); for(Vector&lt;Object&gt; row : data){ // If on the right row, update it if(row.elementAt(searchColumn).equals(searchStudentID)){ row.setElementAt(updateValue, updateColumn); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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