I am executing a simple query on a small table
SELECT * FROM SYSTEM
System table only has three columns(Id, Name, Progress) and 1300 rows.
My code for getting the data is:
try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = (Connection) DriverManager.getConnection( "jdbc:mysql://192.168.0.107:3306/my_database", username.getText(), password.getText()); String query = "select * from system"; stmt = (Statement) conn.createStatement(); rs = (ResultSet) stmt.executeQuery(query); while (rs.next()) { tableModel.addRow(new Object[] { rs.getInt("Number"), rs.getString("Name"), rs.getFloat("Progress") }); } } catch (Exception e) { // some other code }`
This code takes around 15 seconds to display the date in my JTable, while if I execute the query in phpmyadmin it takes less than one second.