Discussions

Web tier: servlets, JSP, Web frameworks: how can we set a character in a prapared statement??

  1. Hai,
      
       for setting int, fload, double, String we have
    setInt(), setFloat(), setDouble(), setString() respectively in prepared statement. how can we set a character from a prepared statement for a database with column type 'char'??

    by
  2. You can use setString() method which can be applied for varchar in database

    Thanks,
    N.Naresh Kumar
  3. setString() works for char as well as varchar. Just bear in mind that if the string value you use is not long enough, the missing values will be padded with null characters.

    This matter mainly for string retrieval: use getString().trim() to eliminate the null characters.