developing a web application using java. I have SQL queries with more than 40 lines ,using " , "+ at staring an end of query respectively. it is very difficult to convert string as query when i want to do any modifications in both both conversions
Can't you use PreparedStatement? If possible, use an ORM tool like hibernate. That will simplify your code (Of course there are other benefits).
If your facing trouble in maintaing the sql query then you could try moving to spring JDBC templace where you can store the query in a config/props file with placeholders/bind variables. This significantly reduces the errorneous part of constructing a string query.
You can simply generalise your queries by creating this kind of methods. Example:
private String DBFormatter="'";
public String FormatSQl(String value)
{
return DBFormatter + value + DBFormatter;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.