
Connect SQL Serveer(RDS) with FireDAC.
The platform used Ubuntu.
Select sqlserver-ex for DB Engine of RDS.
Time Zone setting is Tokyo/Japan.
[Ubuntu "Microsoft ODBC Driver 11 for SQL Server" driver settings]
I tried it with local Ubuntu and RDS(SQL Server).
It is also possible to use EC2(Ubuntu) as shown below.
# sudo apt-get install openssl libkrb5-3 libc6 e2fsprogs sudo ln -s /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/x86_64-linux-gnu/libcrypto.so.10 sudo ln -s /lib/x86_64-linux-gnu/libssl.so.1.0.0 /usr/lib/x86_64-linux-gnu/libssl.so.10 wget http://download.microsoft.com/download/B/C/D/BCDD264C-7517-4B7D-8159-C99FC5535680/RedHat6/msodbcsql-11.0.2270.0.tar.gz tar -xavf msodbcsql-11.0.2270.0.tar.gz sudo bash msodbcsql-11.0.2270.0/install.sh install --accept-license --force
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Connect_to_Microsoft_SQL_Server_(FireDAC)
[Create RAD Studio new Project]
Select [File]→[New]→[Other..]→[Delphi Projects]→[Console Application] from the menu.
//// program sql_server_connection; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; begin try except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
At first it is the above state.
Change the target to "Linux 64Bit".
Please see the URL for the method of adding targets.
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Linux_Application_Development
[Added New Data Module]
Add Data Module.
This is also added from the menu[New]→[Other..].
It was placed TFDConnection in a Data Module.
Set FDConnection1.
# User_Name= UsernameName Password=***** Server=*.*.ap-northeast-1.rds.amazonaws.com DriverID=MSSQL
[Code]
I wrote a simple code for Unit1.pas.SQL to get time with getdate().
//// function TDataModule1.get_sql_date: TDateTime; var query_: TFDQuery; begin query_ := TFDQuery.Create(Self); try query_.Connection := FDConnection1; query_.SQL.Text := 'select getdate() as d_'; query_.Active := True; Result := query_.FieldByName('d_').AsDateTime; finally query_.DisposeOf; end; end;
Call this on the main.
/// var s_: String; begin try try DataModule1 := TDataModule1.Create(nil); s_ := DateTimeToStr(DataModule1.get_sql_date); Writeln(s_); finally DataModule1.DisposeOf; end; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
If you get an error like the one below.
Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0' : file not found' .
# Project * raised exception class EMSSQLNativeException with message '[FireDAC][Phys][ODBC][unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0' : file not found'.
It can be avoided by making ln -s.
# ln -s /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0 /opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
[result]
got the SQL Server time.