-1

I'm trying to execute the following method

String sqlQuery = "UPDATE ACCOUNTS"
                    + " SET LAST_LOGIN_DATE=LOGIN_DATE,"
                    + " LOGIN_DATE=SYSTIMESTAMP" 
                    + " WHERE CUSTOMER_ID=? AND USER_ID=?";

        logger.debug("[{}] sqlQuery={}", methodName, sqlQuery);

        String connectionName = properties.getProperty(JNDI_NAME);
        Connection connection = null;
        PreparedStatement pstmt = null;

            connection = getJNDIConnection(connectionName);
            pstmt = connection.prepareStatement(sqlQuery);
             // set the input parameters
            pstmt.setString(1, customerId);
            pstmt.setString(2, userId);

                        if (pstmt.executeUpdate() > 0)

When I get to the last line it gives me false and the query is not executed. Please, help

Slava Chirița
  • 103
  • 1
  • 2
  • 10

3 Answers3

0

I'm not that familiar with Oracle, but are you sure the JNDI connection is connecting to the same tablespace/database/schema as your SQL console? This answer makes me think maybe you are somehow not connecting to what you think you are.

Community
  • 1
  • 1
brettw
  • 10,664
  • 2
  • 42
  • 59
-1

Try appending table after update like update table ACCOUNTS

shreyansh jogi
  • 2,082
  • 12
  • 20
-1

From the documentation:

Returns: either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing.

The update statement returns nothing, so the executeUpdate will return 0.

Alexei
  • 1,028
  • 1
  • 11
  • 17