mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-18 22:15:20 +02: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>
|
2005-12-22 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/odbc/ejabberd_odbc.erl: Bugfix
|
* src/odbc/ejabberd_odbc.erl: Bugfix
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
handle_info/2,
|
handle_info/2,
|
||||||
terminate/2]).
|
terminate/2]).
|
||||||
|
|
||||||
|
-include("ejabberd.hrl").
|
||||||
|
|
||||||
-record(state, {db_ref, db_type}).
|
-record(state, {db_ref, db_type}).
|
||||||
|
|
||||||
-define(STATE_KEY, ejabberd_odbc_state).
|
-define(STATE_KEY, ejabberd_odbc_state).
|
||||||
|
@ -112,14 +114,22 @@ init([Host]) ->
|
||||||
SQLServer = ejabberd_config:get_local_option({odbc_server, Host}),
|
SQLServer = ejabberd_config:get_local_option({odbc_server, Host}),
|
||||||
case SQLServer of
|
case SQLServer of
|
||||||
{pgsql, Server, DB, Username, Password} ->
|
{pgsql, Server, DB, Username, Password} ->
|
||||||
{ok, Ref} = pgsql:connect(Server, DB, Username, Password),
|
case pgsql:connect(Server, DB, Username, Password) of
|
||||||
{ok, #state{db_ref = Ref,
|
{ok, Ref} ->
|
||||||
db_type = pgsql}};
|
{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) ->
|
_ when is_list(SQLServer) ->
|
||||||
{ok, Ref} = odbc:connect(SQLServer,
|
case odbc:connect(SQLServer,[{scrollable_cursors, off}]) of
|
||||||
[{scrollable_cursors, off}]),
|
{ok, Ref} ->
|
||||||
{ok, #state{db_ref = Ref,
|
{ok, #state{db_ref = Ref, db_type = odbc}};
|
||||||
db_type = odbc}}
|
{error, Reason} ->
|
||||||
|
?ERROR_MSG("ODBC connection (~s) failed: ~p~n",
|
||||||
|
[SQLServer, Reason]),
|
||||||
|
{stop, odbc_connection_failed}
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user