我只是在 Prolog 中测试一个小脚本来健全地检查 MySQL 连接。在建立大约 3000 多个连接后,连接随机失败。MySQL 服务器对连接数是否有任何限制
:-dynamic db_connection/1.
sanity_check_open_db:-
odbc_connect('myDSN', _,
[ user(bob),
password(pop),
alias(myDSN),
open(once)
]),
( db_connection(_),
retractall(db_connection(_))
; assert(db_connection(myDSN))).
sanity_chec_close:-
( db_connection(C),
odbc_disconnect(C),
retractall(db_connection(C))
; write('Error: No connection opened to close')).
sanity_check_open_close(10000).
sanity_check_open_close(N):-
format(atom(C),'~wth Iteration~n',[N]),
write(C),
sanity_check_open_db,
sanity_chec_close,
N1 is N + 1,!,
sanity_check_open_close(N1).