#1 2016-01-07 12:50:08

jkuiper
Member
Registered: 2014-11-24
Posts: 13

Database connection error with ZEOS

My real goal is to connect a databaseserver and get data remotely.
My own first example is working (both Delphi/Lazarus). I created a SQLite database and put some data in it.

My own second example connects to a database server (MariaDB 5.5). I looked in the manual and took the code from chapter 8.1  (Lazarus 1.6Rc1/ FPC 3.0):

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  SynCommons,  mORMot, mORMotSQLite3, SynSQLite3Static,
  mORMotDB,  synDB,  
  SynDBZeos, // needed for Zeos
  ZDbcMySql; // needed for Zeos


type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    procedure UseProps(Props: TSQLDBConnectionProperties);
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var Props: TSQLDBConnectionProperties;
    Server : string;
begin
  Server := 'zdbc:mysql://192.168.x.x:3306/test?username=xxx;password=xxx';
  Props := TSQLDBZEOSConnectionProperties.Create(Server,'test','','');
  try
    UseProps(Props);
  finally
    Props.Free;
  end;
end;

procedure TForm1.UseProps(Props: TSQLDBConnectionProperties);
var I: ISQLDBRows;
begin
  I := Props.Execute('select * from gebruikers where id = ?',['1']);
  showmessage(I.Column['login']);
end;

end.

Examples compiles without problem, but when I want to get data from the database, I get this error:

Project voorbeeld2 raised exception class 'External: SIGSEGV'.

In file 'C:\lazarus16RC1\components\zeoslib714\src\plain\ZPlainMySqlDriver.pas' at line 1240:
Result := PMYSQL_ROW(ROW)[Offset];

It looks the database will not be connected. Is my code wrong or do I have to do something else?

Offline

#2 2016-01-12 08:18:20

jkuiper
Member
Registered: 2014-11-24
Posts: 13

Re: Database connection error with ZEOS

No one will help a beginner who want's to learn mORMot framework?

Offline

#3 2016-01-12 08:35:07

Thomas-Acia
Member
From: Metz (France)
Registered: 2015-04-16
Posts: 79

Re: Database connection error with ZEOS

Hello,
I think you forgot the library driver.
You can find more informations here : http://synopse.info/files/html/Synopse% … #TITLE_182

Last edited by Thomas-Acia (2016-01-12 08:35:32)


Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits

Offline

Board footer

Powered by FluxBB