Is a right behaviour on inserting a duplicate key?
От | Vernon Wu |
---|---|
Тема | Is a right behaviour on inserting a duplicate key? |
Дата | |
Msg-id | DBXT5JUT2YDAQL76C7A5NKCUR73HF.3e46a2f4@kimiko обсуждение исходный текст |
Список | pgsql-jdbc |
I have the following code segment to insert a sign on data which the userid is the primary key of the table: PreparedStatement ps = null; try { getDBConnection(); dbConnection.setAutoCommit(false); // The first step of new user sign up ps = dbConnection.prepareStatement(CREATE_USER_QUERY); ps.setString(1, userName.trim()); ps.setString(2, password.trim()); int result = ps.executeUpdate(); if(result != 1) { logger.error("Unable to create user. Duplicate Key: " + userName); throw new SignOnDAODupKeyException("Unable to create user. " + "Duplicate Key : " + userName); } } catch (SQLException se) { logger.error("SQLException: "+se.getMessage()); throw new DAOSysException("SQLException: "+se.getMessage()); } finally { closeAll(ps); } It seems to me that inserting a duplicate user would result an invalide retured value. Instead, the action leads to a SQL expection as ERROR: Cannot insert a duplicate key into unique index pk_signon Can some clarify the 7.3.1 JDBC driver specification or implement in this regards? Thanks, Vernon
В списке pgsql-jdbc по дате отправления: