Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import java.sql.*;
  2. import javax.swing.*;
  3. public class mysqlconnect {
  4. Connection conn = null;
  5. public static Connection ConnectDb() {
  6. try{
  7. Class.forName("com.mysql.jdbc.Driver");
  8. Connection conn = DriverManager.getConnection("jdbc:mysql://server_name/database_name","user_name","user_password");
  9. return conn;
  10. }catch (Exception e) {
  11. JOptionPane.showMessageDialog(null, "Cant connect to db");
  12. return null;
  13. }
  14. }
  15. }
  16.  
  17. SET SESSION wait_timeout = 999999;//or anything you want
  18.  
  19. SHOW VARIABLES LIKE 'wait_timeout';
  20.  
  21. SHOW VARIABLES LIKE 'connect_timeout';
  22.  
  23. SET GLOBAL connect_timeout=60;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement