Microsoft JDBC Driver for SQL Server連線設定可能碰到的資料型態問題

Recently, I had a problem about slow queries. Table index was a first cause of slow queries; however, the problem was still exists after adding the indexing. Using SQL Server Profiler to trace the queries, there was some queries seem like confused. The column was Varchar but the query use Nvarchar. Therefore, the query didn’t use the indexing so the query became very slow.

After googling and talking to my colleague, we found a method of JDBC DataSource which was “setSendStringParametersAsUnicode“. This method convert Varchar to NVarchar so the indexing was not used.

As a result, this parameter was easy to forget when you were using the Varchar type which was used as a condition.

Leave a comment

Design a site like this with WordPress.com
Get started