0

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

1
  • 4
    it is very difficult to convert string as query when i want to do any modifications This is true. And sad. 40 lines of SQL all written by hand... Feel my condolence... But what is your question? Commented Jan 21, 2013 at 10:35

3 Answers 3

3

Can't you use PreparedStatement? If possible, use an ORM tool like hibernate. That will simplify your code (Of course there are other benefits).

Sign up to request clarification or add additional context in comments.

1 Comment

i am handling already developed project, so now i cant move to struct
1

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.

Comments

0

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;

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.