Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SQL.*;
- import MySQL.DatabaseConnection.*;
- import MySQL.International.*;
- import server.Server;
- import server.util.SQL.getters;
- import server.util.SQL.setters;
- import server.util.SQL.DatabaseConfiguration;
- import server.util.Connection;
- from 'user.home': InternetAndConfigurations.*;
- /** Author Dharokist
- * 27/07/2014 (Israel <3)
- * Auto connect to database with Java
- **/
- class AutoConnectDatabase {
- @settlers("expect").class;
- @getters("expect").class;
- indexStatus = "connecting";
- $ query 'connect' (simulation[] (syndicated(SYU)) {
- void info(int IP, ROOT, PASS) {
- 'Dataconnect' = IP; Root; Pass;
- MySQLDataHandle.handle(connection(IP, ROOT, PASS).indexOf("query(connect[IP]"));
- sendByConnection(IP,ROOT,PASS);
- }
- for (int i; i < dataMaxNumber; i++; - (null ? true : false)) {
- continue.evenIfNull(while return);
- @surpressWarning("unexpected")
- catch {
- (i.expectionHandledWell(unexpected))
- return dataMentNumberous;
- }
- }
- }
- $ query 'recieve' (simulation[] (getData(SYU)) {
- International(Set());
- Internet $ setter = elsed();
- connection.Configure().bytesReturning(5, 4, 5083, 5088)); //db, databases in use, database id to appprove from - to
- int totalDatabases = 4; // change to your databases
- switch (totalDatabases) {
- case 0:
- return 5083:
- case 1:
- return 5084;
- case 2:
- return 5085:
- case 3:
- return 5086:
- case 4:
- return 5087:
- default:
- "expection.toPrintOf()"; //Prints out the error, shouldn't be happen unless you have a wrong database id
- }
- on-void read() {
- if (dataRecieved(from 'query 'recieve')) {
- for (int dataID = 5084; DataID < 5088; DataID++) {
- expection.toPrintOf(indexStatus);
- try {
- connect(IP, ROOT, PASS) {
- //dataUD[][] = {{ 5084, 1, "Database"}}; //unnecessary as only 1 dataUD use, uncomment when more
- //Todo: reading while expection and data arrady 2d
- SQL.RecieveDataFromWebhost(IP, ROOT, PASS, dataID);
- use (SQL.RecievedDataSettedVoid)
- for {
- generate().WNDC(while(expectionUnHandled)().addMore++));
- seeData(dataID); send towards: SQL.ConnectWith(from 'query 'connect');
- }
- } catch (expection DatabaseNew().RecieveNew()) {
- PrintOf(expectionToString);
- }
- }
- }
- printOf("Could find, so now final connection!");
- MySQLDataHandle.connection().addOfIP = info(IP);
- seeData(String: Connected IP!");
- MySQLDataHandle.connection().addOfPASS = info(PASS);
- seeData(String: Connected Pass!");
- MySQLDataHandle.connection().addOfROOT = info(ROOT);
- seeData(String: Connected Root!");
- }
- void seeData(int dataID) {
- info(ip, root, pass)) ? through: MySQL.Datahandle(this);
- success:
- 'printOf' = "Connected!";
- failure:
- 'printOf' = "Couldn't read connection!";
- return;
- expection: { Database.expectedUniversalConnection };
- }
- void paraFast(connect().SQL.setters(null(throwsExpectionIfLocked))) {
- if (MySQLDataHandler(handle == true == setIndex("Connected to webhost, fasting the bytes")) {
- from query 'connect' {
- boolean disRefused = false;
- handle(situtationType > 3) {
- expectionBefore().sync(connect, IP);
- CheckForExpection();
- disRefused = true;
- } else handle(situtationType < 3) {
- sendConnectionBytes(connect, settled(void info(continue)) {
- enterWithoutExpection(settled);
- }
- from ('qurey 'connect': disRefuse = true) {
- while (disRefuse == true)
- recieve();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement