• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question regarding use of StringBuilder in DataBase Connection

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic