mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
* src/odbc/ejabberd_odbc.erl: Added error message on ODBC
connection to help ODBC configuration troubleshooting. SVN Revision: 476
This commit is contained in:
parent
0035c63399
commit
15e747782a
@ -1,3 +1,8 @@
|
||||
2005-12-22 Mickael Remond <mickael.remond@process-one.net>
|
||||
|
||||
* src/odbc/ejabberd_odbc.erl: Added error message on ODBC
|
||||
connection to help ODBC configuration troubleshooting.
|
||||
|
||||
2005-12-22 Alexey Shchepin <alexey@sevcom.net>
|
||||
|
||||
* src/odbc/ejabberd_odbc.erl: Bugfix
|
||||
|
@ -27,6 +27,8 @@
|
||||
handle_info/2,
|
||||
terminate/2]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
-record(state, {db_ref, db_type}).
|
||||
|
||||
-define(STATE_KEY, ejabberd_odbc_state).
|
||||
@ -112,14 +114,22 @@ init([Host]) ->
|
||||
SQLServer = ejabberd_config:get_local_option({odbc_server, Host}),
|
||||
case SQLServer of
|
||||
{pgsql, Server, DB, Username, Password} ->
|
||||
{ok, Ref} = pgsql:connect(Server, DB, Username, Password),
|
||||
{ok, #state{db_ref = Ref,
|
||||
db_type = pgsql}};
|
||||
case pgsql:connect(Server, DB, Username, Password) of
|
||||
{ok, Ref} ->
|
||||
{ok, #state{db_ref = Ref, db_type = pgsql}};
|
||||
{error, Reason} ->
|
||||
?ERROR_MSG("PostgreSQL connection failed: ~p~n", [Reason]),
|
||||
{stop, pgsql_connection_failed}
|
||||
end;
|
||||
_ when is_list(SQLServer) ->
|
||||
{ok, Ref} = odbc:connect(SQLServer,
|
||||
[{scrollable_cursors, off}]),
|
||||
{ok, #state{db_ref = Ref,
|
||||
db_type = odbc}}
|
||||
case odbc:connect(SQLServer,[{scrollable_cursors, off}]) of
|
||||
{ok, Ref} ->
|
||||
{ok, #state{db_ref = Ref, db_type = odbc}};
|
||||
{error, Reason} ->
|
||||
?ERROR_MSG("ODBC connection (~s) failed: ~p~n",
|
||||
[SQLServer, Reason]),
|
||||
{stop, odbc_connection_failed}
|
||||
end
|
||||
end.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user