JDBC connectivity

Database
Enthusiast

JDBC connectivity

Hi is it possible to use modify user statement in the prepared statement as like below.If it is wrong plz correct it....

PreparedStatement pstmt1 = con.prepareStatement("MODIFY USER '"+username+"' AS release password lock;");

3 REPLIES
Enthusiast

Re: JDBC connectivity

k

Teradata Employee

Re: JDBC connectivity

You don't need to use a PreparedStatement for that SQL request, because it does not contain any question-mark parameter markers (and, in fact, you cannot use parameter markers in a DDL command like that).

You code has a problem -- a syntax error -- the username specified in a MODIFY USER command should not be enclosed in single-quotes.

You must also be careful to avoid SQL injection attack. You should enclose the username in double-quotes, and also double any double-quote characters that may be in the username.

Statement stmt = con.createStatement();

stmt.executeUpdate("modify user \"" + username.replaceAll("\"", "\"\"") + "\" as release passwork lock");

Enthusiast

Re: JDBC connectivity

Ya now its working fine!!!!! Thank you