There is no equivalent in Java to PHP magic quotes. Java isn't static like PHP is, so it can monitor in real time these values. Not like you'd want to use it anyway, magic_quotes_gpc in PHP was a terrible idea right from the start.
I'm also not familiar with anything like the real_escape_string in PHP. I've always used prepared statements with Java sql.
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php