Ubuntu under erlang connect SQL SERVER 2008

erlang connect to SQL Server using ODBC method, but is still a lack of information on the Web, toss the 2 genius success. Especially now recorded for all to learn.

The basic idea is  erlang odbcserver + unixodbc + freetds, a complete reference herein the Install ODBC and MS SQL Server Client for Erlang , we can look at the venue.

1.SQL Server 2008 installation

Internet to install SQL Server 2008 a lot, I refer to is to install SQL Server 2008 step by step illustrated tutorials on Win7 system

 

 

2. user password SQL Server 2008

After the installation is complete, the computer can only be installed by the user above the landing, erlang convenient connection to add a user and password. My reference is sqlServer can not use SQL Server Authentication login identity solutions

 

3. Refer to Install ODBC and MS SQL Server Client for Erlang install the driver file

apt-get install freetds-bin freetds-dev tdsodbc

Note: I am using ubuntu system, I also installed centos freetds too, but not included centos official website freetds software, to be obtained by rpmforge. We detour.

 

4. Edit freetds.conf files and file /etc/odbc.ini

Open /etc/freetds/freetds.conf file, find egServer70 keyword, the following ntmachine.domain.com changed IP host you want to connect, for example 192.168.0.95.

Then /etc/odbc.ini inside Servername changed egServer70.

Then, like Install ODBC and MS SQL Server Client for Erlang inside, erlang SQL Server 2008 can connect it via odbc.

Install ODBC and MS SQL Server Client for Erlang which did not say you want to modify these two places, I had to toss a long time, it has not led to the connection.

 

5.ejabberd transaction support for SQL Server.

In ejbberd which, unlike mysql transaction handling instructions, transaction support for SQL Server stored procedure it is entirely based on SQL Server.

In other words, write a SQL Server stored procedure to execute a SQL Server database inside, then erlang support to complete the transaction by calling the stored procedure. We pay careful attention to ejabberd project can be found inside the odbc_queries.erl EXECUTE dbo.xxx code, etc., which is to call a stored procedure in SQL Server.

Careful not previously used the SQL Server, SQL Server now found in the use is still very convenient, very friendly programmer, do not know the performance of other issues such as the fact.

 

2013-12-16 Added:

6. garbled data

Encountered in the process of using the situation garbled, debugging for a long time only to find that in freetds which you can configure.

In /etc/freetds/freetds.conf inside first [Global] block. In the [global] Add the following the following configuration options can solve the garbage problem.

client charset = UFT-8

 

 

 

Reproduced in: https: //my.oschina.net/u/191928/blog/618670

Guess you like

Origin blog.csdn.net/weixin_34249367/article/details/91987012