Advertisement
Guest User

Untitled

a guest
May 24th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. var connection = mysql.createConnection({
  2. host :'localhost',
  3. user : 'root',
  4. password : 'secret',
  5. port:3000
  6. });
  7. connection.connect();
  8.  
  9. //connection.query("SET SESSION wait_timeout = 604800");
  10.  
  11. connection.query('CREATE TABLE t1(id int)', function(error, rows, fields) {
  12. if (error){
  13. throw error;
  14. }else{
  15. console.log(rows);
  16. }
  17. });
  18.  
  19.  
  20.  
  21. connection.query('select * from t1', function(error, rows, fields) {
  22. if (error){
  23. throw error;
  24. }else{
  25. console.log(rows);
  26. }
  27. });
  28.  
  29.  
  30.  
  31. function keepalive() {
  32. connection.query('select 1', [], function(err, result) {
  33. if(err) return console.log(err);
  34. // Successul keepalive
  35. });
  36. }
  37. setInterval(keepalive, 1000*60*5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement