Escape value in MSSQL Server with Java

末鹿安然 提交于 2019-12-25 06:36:34

问题


How can I escape a value for usage in a query to MSSQL Server? I know how it would be possible using JDBC but since I'm using SAP Business One DI API there is no way (I'm aware of) of using prepared statements.

It would be sufficient to know how to escape string values while additionally knowing how to escape identifiers would be nice, too.

Update: After reading New SQL Truncation Attacks And How To Avoid Them it seems sufficient to escape identifiers using [ (and doubling each occurrence of ]) and values using ' (again doubling every occurence of '). A hint to a library whose concern is correct escaping of MSSQL would be nice nevertheless.

来源:https://stackoverflow.com/questions/23477126/escape-value-in-mssql-server-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!