How to escape single quote in sql which is causing' quoted string not properly terminated '?
===

I am trying to read terms from a database (>10K) and i'm using that term in another query . I'm getting this error ' quoted string not properly terminated' in oracle. I did

    term.replaceAll("'","\\'");

but that doesn't seem to do the job from me. Besides, these terms are tokens from documents when they are converted to text.Any regex that can overcome this problem?
The exact sql query is 

    String sql = "Select * from indexDB where (DocID="+d.getDocId()+"and Term='"+ term +"')";



Thanks 