Jump to content

CharacterSet mess. (Solved)


Recommended Posts

Seems to be not uniGui trouble but not sure exactly

 

Having UniGUI app, MySQL DataBase, FireDAC.

 

When trying to insert Russian symbols on local pc- everything ok.

same operation on VPS Asure, having "????????" in spite of normal text.

 

Everything the Same,

-UniGUI EXE file

-MySQL Server

-Database

 

the only difference - my computer and vps computer

 

Doing connection on client like

...
 oParams.Add('DataBase=someDataBase');
  oParams.Add('Password=masterkey');
  oParams.Add('User_Name=root');
  oParams.Add('Port=3306');
  oParams.Add('Server=localhost');
  oParams.Add('CharacterSet=utf8'); // <<<
...

MySQL is adjusted like

 

character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server utf8
character_set_system utf8
character_sets_dir C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\
 
Can't understand that mess. 
 
On local server everyting Ok, on vps - "???????" in spite of normal text in Russian.
 
Looking for advice. Thank you! 
Link to post
Share on other sites

if info is written on database import - everything is Ok, but if to write it on vps throgh unigui client - that mess.

also if to write to database throgh workbench client - everything is ok - some problem in firedac on unigui - can't understand

Link to post
Share on other sites

ok, connected from local pc to remote database - successfully inserted record with russian symbols (see pic)

 

what it means?

 

db - ok!

 

some trouble in the app? firedac? unigui? maybe to update uni files on vps?

post-2378-0-26454400-1490169966_thumb.jpg

Link to post
Share on other sites

That is strange...

Updated runtime and compiler to 1.0.0.1376_RC

Started program, from local computer everything is Ok,

From VPS still '????'

 

about connection, I connect like this - on local pc everything fine. Copying exe to vps and meeting problem

function TUniShopDBConnection.Connect: boolean;

var oParams:TStrings;  ErrorInfo:string;

begin

  //Драйвер << Можно отдельно прописать, если он не в папке с EXE
//  FDPhysMySQLDriverLink1.VendorLib:='C:\MySQLDriver\libmysql.dll';
// либо положить его в c:\windows\SysWow64\

 oParams:=TStringList.Create;


 try

  oParams.Add('DataBase=someDataBase');
  oParams.Add('Password=*****');
  oParams.Add('User_Name=someUser');
  oParams.Add('Port=3306');
  oParams.Add('Server=localhost');
  oParams.Add('CharacterSet=utf8');
//  oParams.Add('Pooled=true');

  FDConnection.Params.Assign(oParams);
  FDConnection.DriverName:='MySQL';
//  UniServerModule.FDManager.AddConnectionDef('MySQL_Pooled','MySQL',oParams);
//  FDConnection.ConnectionDefName := 'MySQL_Pooled';




   //Пробуем подключиться

   try

   FDConnection.Connected:=true;

   if FDConnection.Connected then

     begin
     Result:=true;

//     showmessage('Connected');
     end else Result:=false;



   except



   on E: EFDDBEngineException do

    case E.Kind of
    ekUserPwdInvalid:


       // user name or password are incorrect
       raise Exception.Create('DBConnection Error. User name or password are incorrect'+
       #13#10+#13#10+E.ClassName+' поднята ошибка, с сообщением : '+E.Message);



    ekUserPwdExpired:


      raise Exception.Create('DBConnection Error. User password is expired'
    +#13#10+#13#10+E.ClassName+' поднята ошибка, с сообщением : '+E.Message);



    ekServerGone:



      raise Exception.Create('DBConnection Error. DBMS is not accessible due to some reason'
      +#13#10+#13#10+E.ClassName+' поднята ошибка, с сообщением : '+E.Message);




    else                // other issues



      raise Exception.Create('DBConnection Error. UnknownMistake'
      +#13#10+#13#10+E.ClassName+' поднята ошибка, с сообщением : '+E.Message);





    end;

    on E : Exception do

      raise Exception.Create(
      E.ClassName+' поднята ошибка, с сообщением : '+#13#10+#13#10+E.Message
      );





   end;




 finally

  FreeAndNil(oParams);

 end;


end;

Link to post
Share on other sites

Solution found !!!

 

Changed Locale and Region to Russia on VPS !!! I don't know how it works but it works.

 

Everybody thank you ! I think topic could be useful for others in depoy questions.

 

Go to ControlPanel -> Clock Language and Region and change Region and Locale!

(see pic)

 

 

post-2378-0-47840400-1490176696_thumb.jpg

Link to post
Share on other sites
  • Administrators

Solution found !!!

 

Changed Locale and Region to Russia on VPS !!! I don't know how it works but it works.

 

Everybody thank you ! I think topic could be useful for others in depoy questions.

 

Go to ControlPanel -> Clock Language and Region and change Region and Locale!

(see pic)

 

Probably your MySQL server is using OS character settings.

Link to post
Share on other sites
  • Administrators

Your problem is that your FDConnection is not using utf8 as default characterset.

 

There is something wrong with the way you create Pooled connections. It must be done in ServerModule.

Please see below code.


procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject);
var
  oParams : TStringList;
begin
  FDPhysMySQLDriverLink1.VendorLib := StartPath + 'files\libmysql.dll';

  // Use pooled connections for FireDAC. See: http://docwiki.embarcadero.com/RADStudio/XE6/en/Multithreading_(FireDAC)
  oParams := TStringList.Create;
  try
    oParams.Add('Server=192.168.1.100');
    oParams.Add('User_Name=uni_test_db');
    oParams.Add('Password=*****');
    oParams.Add('Database=unigui_test');
    oParams.Add('Pooled=True');
    oParams.Add('POOL_MaximumItems=100');
    oParams.Add('CharacterSet=utf8'); 

    FDManager1.AddConnectionDef('MySQL_Pooled', 'MySQL', oParams);
  finally
    oParams.Free;
  end;

  FDManager1.Active := True;
end;

In MainModule you will do like this:

procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject);
begin
  FDConnection1.Close;
  FDConnection1.ConnectionDefName := 'MySQL_Pooled';
  FDConnection1.Open;
end;

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...