+1
Исправлен

Server crashing after integrated with MySQL

Leandro Augusto 5 лет назад в Bugs and problems обновлен Vladimir Ovchinnikov (expert) 5 лет назад 11

Hi,

I´m using iRidium Server 32bits and ODBC Server 32bits. Server is connecting with MySQL perfectly.

But when I send a query to insert values on table, Server stop working. When I go to MySQL to look for the record I see almost 500 equals records (like a "loop"), but if you see on code below I only send a query one time on function writeDB(). 


var date = "now()";
var BaseMySQL = new ODBC("root", "123", "MySQLiridium");
var query_head = "INSERT INTO chamada_enfermagem(Posto, Leito, Tipo, Tempo, Data) VALUES(";


function writeDB(info_chamada) //gravar informações no DB
{
if (!BaseMySQL) //if no ODBC object
{
BaseMySQL = new ODBC("root", "123", "MySQLiridium"); // creating ODBC object
if (BaseMySQL)
{
IR.Log(BaseMySQL + " connected!");
}
}
{
var posto = info_chamada.split("_")[0];
var leito = info_chamada.split("_")[1];
var tipo = info_chamada.split("_")[2];
var tempo = info_chamada.split("_")[3];
var query = query_head + '"'+posto+'"' + "," + '"'+leito+'"' + "," + '"'+tipo+'"' + "," + '"'+"00"+'"' + "," + date + ");";
var response = BaseMySQL.Query(query); // SQL query to MySQL database
IR.Log(query);
}
}   

-1

I also tested with OBDC SQLite. Connection ok, but when a send query, server crashes. When I open the table, I see a lot of same records.

-1
На рассмотрении

Hello.

Show the full text of your query in MySQL.

-1

INSERT INTO chamada_enfermagem(Posto, Leito, Tipo, Tempo, Data) VALUES("P2A","215","ATENDIDO","00",now());

I tested this query on MySQL Workbench and it is working.

-1

Hello.

For SQLite, the code should be something like this:

var mybase = new SQL();
var info_chamada = "P2A_215_ATENDIDO_4";
var query_head = "INSERT INTO chamada_enfermagem(Posto, Leito, Tipo, Tempo, Data) VALUES(";
var now = "";
var query = "";

function writeDB(info_chamada)
{
var posto = info_chamada.split("_")[0];
var leito = info_chamada.split("_")[1];
var tipo = info_chamada.split("_")[2];
var tempo = info_chamada.split("_")[3];
query = query_head + '"'+posto+'"' + "," + '"'+leito+'"' + "," + '"'+tipo+'"' + "," + '"'+"00"+'"' + "," + '"' + now + '"' + ");";
IR.Log(query);
}

IR.AddListener(IR.EVENT_START,0,function()
{
mybase.Open("MyBase.db");
mybase.Execute("BEGIN");
now_query = mybase.Request("SELECT date('now');");
now = now_query.GetRowValue(0,0);
IR.Log("now: " + now);
writeDB(info_chamada);
mybase.Execute("CREATE TABLE IF NOT EXISTS chamada_enfermagem(Posto TEXT, Leito TEXT, Tipo TEXT, Tempo TEXT, Data TEXT)");
mybase.Execute(query);
mybase.Execute("COMMIT");
mybase.Close();
now_query.Free();
});

In MySQL should work similarly, only getting the date differently.

-1

Sintax above that you show me is for local database (https://dev.iridi.com/DB_API/en).

I used this sintax for ODBC (https://dev.iridi.com/ODBC/en)

Local data base is OK like your code. But for MySQL is not working.

-1

I made a video. You can view in my code on query and on video you can see 512 rows returned.

My code:

/**************Variables Init**************************/
var now = "now";
var BaseMySQL = new ODBC("root", "123", "MySQLiridium");
var query_head = "INSERT INTO chamada_enfermagem(Posto, Leito, Tipo, Tempo, Data) VALUES(";
var info_chamada = "P2A_215_ATENDIDO_4";

IR.AddListener(IR.EVENT_START,0,function()
{
if(BaseMySQL == false)
{
IR.Log("Wrong connection");
}
else
{
IR.Log("Right connection");
}

writeDB(info_chamada)
});


function writeDB(info_chamada) //gravar informações no DB
{
if (!BaseMySQL) //if no ODBC object
{
var BaseMySQL = new ODBC("root", "123", "MySQLiridium"); // creating ODBC object
if (BaseMySQL)
{
IR.Log(BaseMySQL + " connected!");
}
}

var posto = info_chamada.split("_")[0];
var leito = info_chamada.split("_")[1];
var tipo = info_chamada.split("_")[2];
var tempo = info_chamada.split("_")[3];
var query = query_head + '"'+posto+'"' + "," + '"'+leito+'"' + "," + '"'+tipo+'"' + "," + '"'+"00"+'"' + "," + '"'+now+'"' + ");";
var response = BaseMySQL.Query(query); // SQL query to database
IR.Log(query);

}

-1
Начат

Thank you for the information provided. Error reproduced. We will inform you when the solution is ready.

Check on the attached build.

Attention! These builds are for tests only! Not for production use!

iRidiumServer32.zip

iRidiumServer64.zip

Запланирован

Hello.

We'll let you know when the fix is in the official release.

Исправлен

Hello.

The fix is included in release 1.3.10.

Сервис поддержки клиентов работает на платформе UserEcho