3 Replies Latest reply: Jun 15, 2009 7:30 PM by 807588 RSS

    How to store multiline texts in single database field ?

    800428
      Hi
      I want to store the whole contents of jTextArea (which can contain multiple lines as we know) into a single database field, how to do that ? I am using Java Derby Database.
      Any answer or hint will be well appreciated.
      Thanks
        • 1. Re: How to store multiline texts in single database field ?
          DrClap
          I don't see the problem. You just put the string into that field using an INSERT statement. What have you tried so far?
          • 2. Re: How to store multiline texts in single database field ?
            800428
            thanks for responding.

            i have tried but it doesn't works, for example i tried the following insert query with java derby;

            INSERT INTO USER.EMP VALUES ('sometext'||char(13)||char(10) ||'textinnewline')

            here user is a username and emp is table which has only one field named "*strtext*" of type varchar(100).
            and output is:

            sometext13 10 textinnewline

            i am not getting how to insert a new line char. Can any one of u tell me that how to insert \n in database field?

            Thanks
            • 3. Re: How to store multiline texts in single database field ?
              807588
              Help_Me_Solve wrote:
              thanks for responding.

              i have tried but it doesn't works, for example i tried the following insert query with java derby;

              INSERT INTO USER.EMP VALUES ('sometext'||char(13)||char(10) ||'textinnewline')

              here user is a username and emp is table which has only one field named "*strtext*" of type varchar(100).
              and output is:

              sometext13 10 textinnewline

              i am not getting how to insert a new line char. Can any one of u tell me that how to insert \n in database field?

              Thanks
              WTF?!?

              I wish you would ever ask a clear question that was really about Java. Instead of all kinds of basic programming questions, with very vague parameters, nonsensical code and hardly related to Java at all. I mean. Really. Is that too much to ask?

              So it seems you want to add some line breaks to a String. Then add then to the String. Then create a prepared statement, bind the string to it, and execute. Prob sol.