Advertisement
pleasemore123

Untitled

Aug 28th, 2014
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.    String IP = 127.0.0.1;
  21.    String ROOT = "database.test";
  22.    String PASS = "tellmeyourpassandilltellyoumine";
  23.    int IP, ROOT, PASS;
  24.  
  25.    void StringToInt(syndicate[ints 1-0]) {
  26.            new Settler settler = Object[settler];
  27.            StringToInt(IP);
  28.            int IP = this.IP;
  29.  
  30.            StringToInt(ROOT);
  31.            int ROOT = this.ROOT;
  32.  
  33.            StringToInt(PASS);
  34.            int PASS = this.PASS;
  35.    }
  36.    indexStatus = "connecting";
  37.    $ query 'connect' (simulation[] (syndicated(SYU)) {
  38.      void info(int IP, ROOT, PASS) {
  39.           'Dataconnect' =
  40.            IP; Root; Pass;
  41.            MySQLDataHandle.handle(connection(IP, ROOT, PASS).indexOf("query(connect[IP]"));
  42.            sendByConnection(IP,ROOT,PASS);
  43.      }
  44.  
  45.      for (int i; i < dataMaxNumber; i++; - (null ? true : false)) {
  46.           continue.evenIfNull(while return);
  47.           @surpressWarning("unexpected")
  48.           catch {
  49.                  (i.expectionHandledWell(unexpected))
  50.                   return dataMentNumberous;
  51.           }
  52.      }
  53.    }
  54.  
  55.   $ query 'recieve' (simulation[] (getData(SYU)) {
  56.      International(Set());
  57.      Internet $ setter = elsed();
  58.      connection.Configure().bytesReturning(5, 4, 5083, 5088)); //db, databases in use, database id to appprove from - to
  59.      int totalDatabases = 4; // change to your databases
  60.      switch (totalDatabases) {
  61.            case 0:
  62.                  return 5083:
  63.            case 1:
  64.                  return 5084;
  65.            case 2:
  66.                  return 5085:
  67.            case 3:
  68.                  return 5086:
  69.            case 4:
  70.                  return 5087:
  71.            default:
  72.                  "expection.toPrintOf()"; //Prints out the error, shouldn't be happen unless you have a wrong database id
  73.      }    
  74.      on-void read() {
  75.      if (dataRecieved(from 'query 'recieve')) {
  76.            for (int dataID = 5084; DataID < 5088; DataID++) {
  77.                    expection.toPrintOf(indexStatus);
  78.                    try {
  79.                         connect(IP, ROOT, PASS) {
  80.                        
  81.                         //dataUD[][] = {{ 5084, 1, "Database"}}; //unnecessary as only 1 dataUD use, uncomment when more
  82.                         //Todo: reading while expection and data arrady 2d
  83.                         SQL.RecieveDataFromWebhost(IP, ROOT, PASS, dataID);
  84.                         use (SQL.RecievedDataSettedVoid)
  85.                         for {
  86.                             generate().WNDC(while(expectionUnHandled)().addMore++));
  87.                             seeData(dataID); send towards: SQL.ConnectWith(from 'query 'connect');
  88.                             $ query 'connectFast';
  89.                            
  90.                    } catch (expection DatabaseNew().RecieveNew()) {
  91.                         PrintOf(expection().ToString);
  92.                    }
  93.             }
  94.       }
  95.                        
  96.      printOf("Connection found, so now final connecting!");
  97.      MySQLDataHandle.connection().addOfIP = info(IP);
  98.      seeData(String: Connected IP!");
  99.     MySQLDataHandle.connection().addOfPASS = info(PASS);
  100.     seeData(String: Connected Pass!");
  101.      MySQLDataHandle.connection().addOfROOT = info(ROOT);
  102.      seeData(String: Connected Root!");
  103.     }  
  104.  
  105.    void seeData(int dataID) {
  106.            $ see BuildString[]: 'false' return, 'true' continue;
  107.            info(ip, root, pass)) ? through: MySQL.Datahandle(this);
  108.            success:
  109.                        'printOf' = "Connected!";
  110.            failure:
  111.                        'printOf' = "Couldn't read connection!";
  112.           return;
  113.           expection: { Database.expectedUniversalConnection };
  114.  
  115.    }
  116.  
  117.    void connectFast(connect().SQL.setters(null(throwsExpectionIfLocked))) {
  118.          if (MySQLDataHandler(handle == true == setIndex("Connected to webhost, fasting the bytes")) {
  119.             $ from query 'connect' {
  120.                 boolean disRefused = false;
  121.                 int situtationType = 0;
  122.                 situtationType++;
  123.                 handle(situtationType > 3) { // idk why it does that after 2 mins (probably happen cause of the host refreshing of w/e so we do it ourself)
  124.                         expectionBefore().sync(connect, IP);
  125.                         CheckForExpection(); //Returned false? add enterWithoutExpection(settled);
  126.                         $ from 'query 'connect' ? true;
  127.                         $ from 'query 'info' ? continue;
  128.                         Simulator simulation = BuildString[];
  129.                         disRefused = true;
  130.                 } else handle(situtationType < 3) {
  131.                          sendConnectionBytes(connect, settled(void info(continue)); //so it keeps sending the info thought we tackled a leak
  132.                          enterWithoutExpection(settled);
  133.                 }
  134.                 from ('qurey 'connect': disRefuse = true) {
  135.                 while (disRefuse == true)
  136.                        recieve();
  137.                        $ SQL.AddTo(lineAbove): BuildString[dataID]; //Why? so theres a string for nulling expection
  138.                 }
  139.          }
  140.   }
  141.  
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement