Use escape character, for oracle it should be "\".
http://orafaq.com/faq/how_does_one_escape_special_characters_when_writing_sql_queries
http://orafaq.com/faqsql.htm
If you write it in Java, you need an extra escape character.
e.g.
String query = "select * from my_table where id = '\\%'";
Thanks but I should have said a string with special characters in it
exaample:
String pass = "test@2pm";
String user = "me";
sql = "Alter user " +user+ " identified by " + pass;
my prblem is escaping the complete string, have tried various, but no success. How to I escape the string password.
Thanks
You shouldn't be mucking about with escapes - Oracle has already written all of the code, as have most of the thin driver providers.String update = "Alter user ? identified by ?";
PreparedStatement pstmt = connection.prepareStatement(update);
pstmt.setString(1, userName);
pstmt.setString(2, password);
pstmt.executeUpdate();
...
Using PreparedStatements is always your best bet for avoiding bad escapes and SQL injection problems.
> You shouldn't be mucking about with escapes - Oracle
> has already written all of the code, as have most of
> the thin driver providers.String update =
> "Alter user ? identified by ?";
> PreparedStatement pstmt =
> connection.prepareStatement(update);
> pstmt.setString(1, userName);
> pstmt.setString(2, password);
> pstmt.executeUpdate();
> ...
Using PreparedStatements is always your
> best bet for avoiding bad escapes and SQL injection
> problems.
Is that what the OP meant? Good for you.