Re: mysql-connector-net-6.9.3 bug.
Posted by: KIM WANJUN
Date: September 14, 2014 07:22PM

Pattern A :

1 MySqlConnection.open();
2
3 for()
4 {
5 MySqlDataAdapter.AddToBatch();
6 }
7 MySqlDataAdapter.ExecuteBatch();
8 MySqlDataAdapter.ClearBatch();
9
10 MySqlConnection.close();


There is no problem if open() is called before AddToBatch() like above.
But the value of connection.commandInterceptor is null if AddToBatch() is followed by open() like below.

Pattern B :

1 for()
2 {
3 MySqlDataAdapter.AddToBatch();
4 }
5 MySqlConnection.open();
6 MySqlDataAdapter.ExecuteBatch();
7 MySqlDataAdapter.ClearBatch();
8 MySqlConnection.close();

Does the function AddToBatch() needs DB connection ? No. AddToBatch() just add commands to it's internal list container Object. It's totally not related with DB Server.
Then why the Pattern B is problem ? Because DB query to get @@sql_mode was added to AddToBatch(). So If there is no connection you will face problems.
Actually, pattern B is more efficient. It minimize the connection time. Moreover, getting @@sql_mode query in AddToBatch() is almost useless except very special cases.

"connection.commandInterceptor is null" means it's not connected.
So the error at AddToBatch() without connection will be "Connection not established" not "nullpointerexception".

Thanks.

Options: ReplyQuote


Subject
Written By
Posted
September 12, 2014 01:09AM
Re: mysql-connector-net-6.9.3 bug.
September 14, 2014 07:22PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.