Advertisement
Guest User

Untitled

a guest
Mar 14th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. set global max_connections = 200;
  2.  
  3. public class ParserMain {
  4. public static void main(String[] args) throws java.io.IOException {
  5. // Общее число сообщений
  6. int total_entries = 12000;
  7. // Кол-во потоков
  8. int thread_count = 25;
  9. // Кол-во записей на поток
  10. int entries_thread = total_entries / thread_count;
  11. // Начальный инкремент потока
  12. int thread_end;
  13. // Конечный инкремент потока
  14. int thread_start;
  15.  
  16. for (int i = 1; i <= thread_count; ++i) {
  17. thread_end = i * entries_thread;
  18. thread_start = thread_end - entries_thread;
  19. new ParserThread(thread_start, thread_end).start();
  20. }
  21. }
  22. }
  23.  
  24. public class ParserThread extends Thread {
  25. private int jstart;
  26. private int jend;
  27.  
  28. protected Connection conn;
  29. protected PreparedStatement ps;
  30. protected Statement st;
  31. protected ResultSet rs;
  32.  
  33. public ParserThread(int jstart, int jend) {
  34. this.jstart = jstart;
  35. this.jend = jend;
  36. }
  37.  
  38. public void run() {
  39. String dbDriver = "org.gjt.mm.mysql.Driver";
  40. String dbHost = "jdbc:mysql://localhost/test?autoReconnect=true";
  41.  
  42. try {
  43. Class.forName(dbDriver);
  44. conn = DriverManager.getConnection(dbHost, "root", "");
  45. } catch (Exception e) {
  46. System.err.println(e.getMessage());
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement