Updating a chkpass column in postgres v8.1.21

Поиск
Список
Период
Сортировка
От Nelson, Howard C
Тема Updating a chkpass column in postgres v8.1.21
Дата
Msg-id E09F36BE99E21348A724147F0DA2F07301358697@HDXDSP51.us.lmco.com
обсуждение исходный текст
Ответы Re: Updating a chkpass column in postgres v8.1.21  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice

I am using the JDBC prepareStatement object to build a SQL statement that should update a users password in a postgres v8.1.21 database.  (Based on what I have read, chkpass became a “contrib module” starting at 8.3, but I have to use an older version of postgres.)  Here is my java code/snippet:

 

// Build an SQL statement with caller's parameters

private static final String m_defaultPass = "changeme";   

stmtStr = "UPDATE users SET pwd_date=now(), pwd=? " + "WHERE user_id=?;";

stmt = con.prepareStatement(stmtStr);

stmt.setString(1, m_defaultPass);

stmt.setString(2, userId);

    

(userId is a String that is passed into the method)

 

The password column in the database is defined as type chkpass.

userdb=# \d users

                                               Table "public.users"

      Column       |            Type             |                             Modifiers

-------------------+-----------------------------+-------------------------------------------------------------------

user_pk           | integer                     | not null default nextval(('"users_user_pk_seq"'::text)::regclass)

user_id           | character varying(10)       | not null

pwd               | chkpass                     | not null

 :

 

chkpass is a user created type, and is defined as follows:

CREATE TYPE chkpass (

    INTERNALLENGTH = 16,

    INPUT = chkpass_in,

    OUTPUT = chkpass_out,

    ALIGNMENT = int4,

    STORAGE = plain

);

 

When the above java snippet is executed, I get the following error:

   column "pwd" is of type chkpass but expression is of type character varying.

 

How do I modify my SQL statement to get this to work properly?

 

Thanks in advance!

Howard

 

В списке pgsql-novice по дате отправления:

Предыдущее
От:
Дата:
Сообщение: PG_DUMP producing incorrect SQL
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Updating a chkpass column in postgres v8.1.21