让 JTDS 驱动程序接受 sendStringParametersAsUnicode=false 时出现问题?
一直使用 net.sourceforge.jtds.jdbc.Driver 作为我所有应用程序的 MSSQL 驱动程序。我在准备好的语句中遇到性能问题,并了解到 sendStringParametersAsUnicode=false 应该可以解决该问题。不幸的是,我似乎无法让司机接受这个值。我可以让 Microsoft 驱动程序 com.microsoft.sqlserver.jdbc.SQLServerDriver 很好地接受该参数:
jdbc:sqlserver://servername:1433;databaseName=dbname;sendStringParametersAsUnicode=false
在 persistence.xml 和我的 ds.xml 中工作。准备好的语句执行速度很快,22 秒内完成 100 条语句。
然而,我似乎无法从 JTDS 中获得同样的性能提升。它仍然挂在准备好的语句周围,每次迭代都需要几秒钟。
我已经尝试了该字符串的几种变体,并且在我的测试(带有 Hibernate.connection.url 的 persistence.xml)以及带有 JTA 和 ds.xml 的服务器中看到了相同的延迟。
jdbc:jtds:sqlserver://server:1433/dbname;sendStringParametersAsUnicode=false
jdbc:jtds:sqlserver://server:1433;sendStringParametersAsUnicode=false;databaseName=dbname
jdbc:jtds:sqlserver://server:1433;sendStringParametersAsUnicode=false;selectMethod=cursor;socketKeepAlive=true;databaseName=dbname
我读到的所有内容都表明 Microsoft 驱动程序速度较慢,并且我的公司过去曾遇到过问题。如果可能的话,我真的很想使用 JTDS,但等不及准备好的语句 10 秒!
有人有什么想法吗?
谢谢
Been using net.sourceforge.jtds.jdbc.Driver as my driver from MSSQL for all my applications. I had trouble with performance in a prepared statement, and learned that sendStringParametersAsUnicode=false should fix the problem. Unfortunately, I can't seem to get the driver to accept the value. I CAN get the Microsoft driver com.microsoft.sqlserver.jdbc.SQLServerDriver to accept the parameter just fine:
jdbc:sqlserver://servername:1433;databaseName=dbname;sendStringParametersAsUnicode=false
works in a persistence.xml, and in my ds.xml. Prepared statements go quickly, 100 in 22 seconds.
However, I can't seem to get the same performance boost out of JTDS. It still hangs around the prepared statement, taking several seconds on each iteration.
I've tried several variations on the string, and see the same lag in my tests (persistence.xml with Hibernate.connection.url) and Server with JTA and ds.xml.
jdbc:jtds:sqlserver://server:1433/dbname;sendStringParametersAsUnicode=false
jdbc:jtds:sqlserver://server:1433;sendStringParametersAsUnicode=false;databaseName=dbname
jdbc:jtds:sqlserver://server:1433;sendStringParametersAsUnicode=false;selectMethod=cursor;socketKeepAlive=true;databaseName=dbname
Everything I've read states the Microsoft driver is slower, and my company had issues with it in the past. I'd really like to use JTDS if possible, but can't wait for a prepared statement for 10 seconds!
Anyone had any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
sendStringParametersAsUnicode
的文档指出:因此,如果将其包含在您的查询中会使您的性能更差,则表明它不适合您的查询,并且您所看到的正是文档警告的问题。
如果您看到 MS 驱动程序中的性能提升,则
sendStringParametersAsUnicode
在 JTDS 上的含义可能与 MS 驱动程序上的含义略有不同。使用和不使用该选项时每个驱动程序的性能如何?您使用什么版本的 SQL Server?您的查询分析器为这些查询显示什么?您的查询是什么以及涉及的字段类型是什么?
The documentation for
sendStringParametersAsUnicode
states:So if including it in your query is making your performance worse, that suggests it's not appropriate for your query, and you're seeing exactly the problems the documentation warns about.
If you are seeing a performance boost in the MS driver, it's possible that
sendStringParametersAsUnicode
has a subtly different meaning on JTDS than on the MS driver.What's the performance of each driver like with and without the option? What version of SQL Server are you using? What does your query profiler show for these queries? What's your query and what are the types of the fields involved?