C
# Cyrille37 #
Hello all,
I come to you to getting help for managing multi threading and database connection.
My project use Xml-Rpc to receive messages, so each call come from a different
thread.
Incoming calls are executing SQL on a MysqlConnection.
MysqlConnection does not like when concurents calls appends.
For a fast and dirty solution, I've put a Monitor() at messages arrived.
But I would like to finally got a nicer solution.
What do you think about the architecture I should make ?
Should I create and manage a Pool of MysqlConnection and only locking when pool
is fully occuped ?
Do you know already made solutions for that case ?
Thanks a lot for you comments and ideas,
cyrille.
PS: Before I put the ugly Monitor, I got some errors like :
Exception: Connection must be valid and open. StackTrace:
at MySql.Data.MySqlClient.MySqlCommand.CheckState()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
Exception: Expected prepared statement marker. StackTrace:
at MySql.Data.MySqlClient.NativeDriver.Prepare(String sql, String[] parmNames)
at MySql.Data.MySqlClient.MySqlCommand.Prepare()
I come to you to getting help for managing multi threading and database connection.
My project use Xml-Rpc to receive messages, so each call come from a different
thread.
Incoming calls are executing SQL on a MysqlConnection.
MysqlConnection does not like when concurents calls appends.
For a fast and dirty solution, I've put a Monitor() at messages arrived.
But I would like to finally got a nicer solution.
What do you think about the architecture I should make ?
Should I create and manage a Pool of MysqlConnection and only locking when pool
is fully occuped ?
Do you know already made solutions for that case ?
Thanks a lot for you comments and ideas,
cyrille.
PS: Before I put the ugly Monitor, I got some errors like :
Exception: Connection must be valid and open. StackTrace:
at MySql.Data.MySqlClient.MySqlCommand.CheckState()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
Exception: Expected prepared statement marker. StackTrace:
at MySql.Data.MySqlClient.NativeDriver.Prepare(String sql, String[] parmNames)
at MySql.Data.MySqlClient.MySqlCommand.Prepare()