title: Delete in JTable with connect SQL?
body: <p>I want to delete  data whole row i choose when i press in the Id's column , so i try with this code but i have this error : &quot;java.sql.SQLException: Conversion failed when converting the nvarchar value 'T123                ' to data type int. &quot;  'T123' is a Id's data</p>
  <pre><code> if (e.getSource() == delete) //button delete {
          int ret = JOptionPane.showConfirmDialog(this, &quot;Do you want to delete?&quot;, &quot;Confirm&quot;, JOptionPane.YES_NO_OPTION);
          if (ret != JOptionPane.YES_OPTION) {
              return;
          }
          Connection c = null;
          PreparedStatement ps = null;
          String url = &quot;net.sourceforge.jtds.jdbc.Driver&quot;;
          int id = tb.getSelectedRow();
          try {
              Class.forName(url);
              String db = &quot;jdbc:jtds:sqlserver://DUCTHANG:1433/student&quot;;
              c = DriverManager.getConnection(db, &quot;username&quot;, &quot;password&quot;);
              ps = c.prepareStatement(&quot;Delete From info where ID = ?&quot;);
              ps.setInt(1, id); //first column's value was choose in table
              ret = ps.executeUpdate();
              if (ret != -1) {
                  JOptionPane.showMessageDialog(this, &quot;This Student has been deleted&quot;);
              }
          } catch (Exception ex) {
              ex.printStackTrace();
          } finally {
              try {
                  if (c != null) {
                      c.close();
                  }
                  if (ps != null) {
                      ps.close();
                  }
              } catch (Exception ex2) {
                  ex2.printStackTrace();
              }
          }
      }
  </code></pre>