简体   繁体   中英

Slow mysql response query


i have made a connection with java and driver mysql in eclipse,all is ok but when i try to send a request to database,the response is very slow,it take more than 1 minute.
THANKS

package connection_mysql;
import java.sql.*;

` public class Main { private static Connection connect = null; private static Statement statement = null; private static PreparedStatement preparedStatement = null; private static ResultSet resultSet = null;

 public static void main(String[] args) {
    String pilote = "com.mysql.jdbc.Driver";
    System.out.println("---------------------------");
    try{
        Class.forName(pilote);
        System.out.println("---------1------------------");
        connect = DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
                  + "user=sqluser&password=sqluserpw");
        Statement statement = connect.createStatement();
        ResultSet resultSet = statement
                  .executeQuery("select * from FEEDBACK.COMMENTS");

        while(resultSet.next()){
            System.out.println("---------------------------");
            System.out.println("nom etudiant "+resultSet.getString("myuser"));
        }
    }catch(Exception e){
        System.out.print("errooor"+e);
  }

  }

  }

Database performance is predicated on schema design and the type of query being run, in addition to the amount and distribution of data in the various tables and their attributes. When you get really crazy, "out of bounds" performance, the first thing to check is that you've not done something silly like try to fetch a terrabyte of data through a super-slow link.

We'll need a LOT more information to be able to help you!

Your FIRST thing to do is try your access through the most simple tools available, like a "terminal monitor." If it performs badly there, you must look at your fundamentals.

Connection time should not be factored in with query execution time. Put time-stamps between the steps to see where the time lag is really going. Creating a new connection can be expensive though a full minute seems very excessive.

If you think this is because of eclipse then run this program in console and check how much time it takes there. If it takes same time then there is problem with your JDBC Driver or Database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM