在我的应用程序中,我想要外部化SQL查询(例如在.properties文件中)。但有时我必须将文本文件的全部内容插入到CLOB列中。
这是我现在使用的代码:
String requete = "the content of the file in xml";
PreparedStatement prepareStatement = con.prepareStatement("INSERT INTO \"TABLE\".\"_XML\" (ID, BLOC_XML) VALUES ('1',?)");
prepareStatement.setCharacterStream(1, new StringReader(requete), requete.length());
我真的需要将SQL逻辑与应用程序业务逻辑分离。有任何解决这个问题的建议。
感谢。
答案 0 :(得分:0)
外部化SQL查询不是一个好主意。想象一下,有人会将.properties文件更改为
drop table really_important_stuff;
此外,作为开发人员,我更希望SQL查询尽可能接近源代码。所以我不需要在其他资源中查找它们。
例如,使用DAO pattern来控制复杂性很简单。