The first argument to replaceAll() is a regular expression and in a regular expression the $ characters is a Meta characters and means the end of line. To replace a $ you must escape it in the regular expression so that it no longer has it's special meaning and the simplest way is to prefix it by \\ . Note - the \\ is needed rather than just \ because Java uses \ as a Meta character ! Messy but ... .
Welcome to the Ranch
Are you trying to pick up the dollar sign with a regular expression? But in regular expressions the dollar sign means the end of the line. You can find out all about it in the Java Tutorials. You might have to escape the dollar signs like this \\$
It looks like you want to use this to replace parameters in an SQL statement. Instead of manually trying to build an SQL statement like this, you should use PreparedStatement instead. This is more efficient (the database can cache the statement, so that it doesn't need to interpret it every time you execute it) and safer (because the JDBC driver will escape special characters, which prevents SQL injection attacks).