View difference between Paste ID: cH4QYqdm and LhbXttNA
SHOW: | | - or go back to the newest paste.
1
import SQL.*;
2
import MySQL.DatabaseConnection.*;
3
import MySQL.International.*;
4
5
import server.Server;
6
import server.util.SQL.getters;
7
import server.util.SQL.setters;
8
import server.util.SQL.DatabaseConfiguration;
9
import server.util.Connection;
10
from 'user.home': InternetAndConfigurations.*;
11
12
 /** Author Dharokist
13
   * 27/07/2014 (Israel <3)
14
   * Auto connect to database with Java
15
 **/
16
class AutoConnectDatabase {
17
@settlers("expect").class;
18
@getters("expect").class;
19
20
   indexStatus = "connecting";
21
   $ query 'connect' (simulation[] (syndicated(SYU)) {
22
     void info(int IP, ROOT, PASS) {
23
          'Dataconnect' = IP; Root; Pass;
24
           MySQLDataHandle.handle(connection(IP, ROOT, PASS).indexOf("query(connect[IP]"));
25
           sendByConnection(IP,ROOT,PASS);
26
     }
27
28
     for (int i; i < dataMaxNumber; i++; - (null ? true : false)) {
29
          continue.evenIfNull(while return);
30
          @surpressWarning("unexpected")
31
          catch {
32
                 (i.expectionHandledWell(unexpected))
33
                  return dataMentNumberous;
34
          }
35
     }
36
   }
37
38
  $ query 'recieve' (simulation[] (getData(SYU)) {
39
     International(Set());
40
     Internet $ setter = elsed(); 
41
     connection.Configure().bytesReturning(5, 4, 5083, 5088)); //db, databases in use, database id to appprove from - to
42
     int totalDatabases = 4; // change to your databases
43
     switch (totalDatabases) {
44
           case 0:
45
                 return 5083:
46
           case 1:
47
                 return 5084;
48
           case 2:
49
                 return 5085:
50
           case 3:
51
                 return 5086:
52
           case 4:
53
                 return 5087:
54
           default:
55
                 "expection.toPrintOf()"; //Prints out the error, shouldn't be happen unless you have a wrong database id
56
     }    
57
     on-void read() {
58
     if (dataRecieved(from 'query 'recieve')) {
59
           for (int dataID = 5084; DataID < 5088; DataID++) {
60
                   expection.toPrintOf(indexStatus);
61
                   try {
62
                        connect(IP, ROOT, PASS) {
63
                        //dataUD[][] = {{ 5084, 1, "Database"}}; //unnecessary as only 1 dataUD use, uncomment when more
64
                        //Todo: reading while expection and data arrady 2d
65
                        SQL.RecieveDataFromWebhost(IP, ROOT, PASS, dataID);
66
                        use (SQL.RecievedDataSettedVoid)
67
                        for {
68
                            generate().WNDC(while(expectionUnHandled)().addMore++));
69
                            seeData(dataID); send towards: SQL.ConnectWith(from 'query 'connect');
70
71
                            }
72
                   } catch (expection DatabaseNew().RecieveNew()) {
73
                        PrintOf(expectionToString);
74
                   }
75
            }
76
      }
77
                        
78
     printOf("Could find, so now final connection!");
79
     MySQLDataHandle.connection().addOfIP = info(IP);
80
     seeData(String: Connected IP!");
81
     MySQLDataHandle.connection().addOfPASS = info(PASS);
82
     seeData(String: Connected Pass!");
83
     MySQLDataHandle.connection().addOfROOT = info(ROOT);
84
     seeData(String: Connected Root!");
85
     }   
86
87
    void seeData(int dataID) {
88
            info(ip, root, pass)) ? through: MySQL.Datahandle(this);
89
            success:
90
                        'printOf' = "Connected!";
91
            failure:
92
                        'printOf' = "Couldn't read connection!";
93
           return;
94
           expection: { Database.expectedUniversalConnection };
95
96
    }
97
98
    void paraFast(connect().SQL.setters(null(throwsExpectionIfLocked))) {
99
          if (MySQLDataHandler(handle == true == setIndex("Connected to webhost, fasting the bytes")) {
100
              from query 'connect' {
101
                 boolean disRefused = false;
102
                 handle(situtationType > 3) {
103
                         expectionBefore().sync(connect, IP);
104
                         CheckForExpection();
105
                         disRefused = true;
106
                 } else handle(situtationType < 3) {
107
                 sendConnectionBytes(connect, settled(void info(continue)) {
108
                          enterWithoutExpection(settled);
109
                 }
110
                 from ('qurey 'connect': disRefuse = true) {
111
                 while (disRefuse == true)
112
                        recieve(); 
113
                 }
114
          }
115
   }
116
117
}