my gen_server hangs with odbc

info info@REDACTED
Mon Jun 15 16:29:26 CEST 2009


Hi All,
I try to check the ODBC module by sending a simple wrong message:
gen_tcp(S,"hello").
I expected to receive an error message such as "SQL syntax error" but my gen_server terminates !
the Reason is {function_clause,odbc, sql_query ...
This is my init:
init(State) ->
 process_flag(trap_exit,true),
 case odbc:start() of
  ok ->
 ConnectString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=jphconstantincom3; User=root;Password=asticot;Option=3;",
 case odbc:connect(ConnectString, [{scrollable_cursors,off}]) of
 {ok,Conn} ->
 {ok, Conn}; 
{error,Reason} ->
io:format("ODBC Connection error; ~s~n",[Reason]),
{ok,odbc_error}
end;
Other ->
io:format("ODBC Connection error; ~s~n",[Other]),
{stop,odbc_not_started} end.
This is my method:
mysql(Msg)->
  gen_server:cast(?MODULE,Msg).
And this is my handle_cast:
handle_cast(Msg, Conn) ->
case odbc:sql_query(Conn,Msg) of   <<<<<<<<<<<<<<<<<<<<<< hangs here 
{updated,Return} ->
io:format("Answer: ~s Msg: ~s~n",[Return,Msg]); 
{error,Reason}->
io:format("ODBC error: ~s~n",[Reason])
end,
{noreply, Conn}.


More information about the erlang-questions mailing list