• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question regarding use of StringBuilder in DataBase Connection  RSS feed

 
samir vasani
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




Dont Consider Commented Code

My question is what is the use of StringBuilder in the belowe code

database = (new StringBuilder(String.valueOf(database))).append(filename.trim()).append(";DriverID=22;READONLY=true}").toString();

please explain the above line.
 
Gabrielle Littler
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Samir,

I suggest you take that line of code and rewrite it to have only one method call per line. That way you might have a better chance of being able to understand what it's doing.
 
Campbell Ritchie
Marshal
Posts: 55759
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't you write that code yourself?

You are repeatedly adding text to the end of the StringBuilder, then getting its value as a String with the toString method and applying the name "database" to that with the assign operator.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!