java - Insert to jTable date from MySQL -
Hello I'm jTable and I need to date jTable for this SQL query. But I can not include the jTable date from the rank, the second date is correct, but jTable 6 columns are empty.
try {class.forName ("com.mysql.jdbc.Driver"); Connection thief = (connection) DriverManager.getConnection ("JDBC: mysql: // local host: 3306 / db_mafia useUnicode = true & characterEncoding = UTF8", "root", "qwerty"); Statement ST2 = con.createStatement (); ResultSet result2 = st2.executeQuery (select ". T *, @rank: = @Rank + as the post \ 1 n" + "(select id_user, (Select from users the nickname where id_user = id ), (Where name selects id_user = id), (select the nickname from users where id_user = id), by SUM (digit) as the number \ n by the number "n" + by the ASC by the id_user command group ) T "); While (result2.next ()) {(DefaultTableModel) jTable1.getModel ()). AddRow (new object [] {result2.getString (1), result2.getString (2), result2.getString (3), result2.getString (4), result2.getString (5), result 2.getstring (6)} );} Result2 .Submit (); } Hold (exception e) {JOptionPane.showMessageDialog (null, e); E.printStackTrace (); System.exit (1); }
And before the query I want to execute it but I do not know where to put it?:
SET @ank = 0;
Select with rank 0 before the rank var: st2.executeUpdate ( "SET @ rank = 0");
Try {class.forName ("com.mysql.jdbc.Driver"); Connection thief = (connection) DriverManager.getConnection ("JDBC: mysql: // local host: 3306 / db_mafia useUnicode = true & characterEncoding = UTF8", "root", "qwerty"); Description st2 = con.createStatement (); St2.executeUpdate ("SET @ank = 0"); Results result 2 = st2.executeQuery ("select t. *, Rank = \ ranks = 1 \ n" + "from (select id_user, (by selecting the user name where id_user = id), (users Selection Number from where id_user = id), (Select the nickname from users where id_user = id), by SUM (digit), by number \ n "+" by id ASUS by the ASC command group) T); While (result2.next ()) {(DefaultTableModel) jTable1.getModel ()). AddRow (New Object [] {result2.getString (1), result2.getString (2), result2.getString (3), Results 2 GetString (4), Results 2 .getString (5), Results 2 .getString (6) }); } Result2.close (); } Hold (exception e) {JOptionPane.showMessageDialog (null, e); E.printStackTrace (); System.exit (1); }
Comments
Post a Comment