Skelett MySQL

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Adrihun

Member
Feb 1, 2017
368
6
0
Is there any way to make it so if skript can't connect to my MySQL database, it will
execute console command "stop"
I have been trying to solve this problem for months now, and I still can't figure out how to do it.

Please if you know MySQL & Skript, help me with this. Thanks!
 
Not solved that good, but works as wished^^

code_language.skript:
script options:
    $ db url jdbc:mysql://HOST:3306/TABLE
    $ db username USER  
    $ db password PASS

function checkSQLConnection(~: int = 0) :: boolean:
    update "CREATE TABLE IF NOT EXISTS `isOnline` (`id` int(11), `uid` int(11))"
    update "INSERT INTO `isOnline` (`id`, `uid`) VALUES ('1', '31273')"
    set {_result::*} to objects in column "uid" from result of query "SELECT uid FROM isOnline WHERE id='1'" and close
    update "DROP TABLE `isOnline`"
    if "%{_result::*}%" is not "<none>":
        return true
    else:
        return false

on script load:
    $ thread
    set {_connected} to checkSQLConnection()
    {_connected} is false:
        send "&4ERROR: NO DATABASE CONNECTION!" to console
        execute console command "/stop"
 
Status
Not open for further replies.