java.sql.SQLSyntaxErrorException: ORA-00972: identifier is too long
<p>I am trying to insert JWT token in database for particular user_id(column) before sending it out to the client. </p>

<pre><code>public void saveTokenToDB(String email, String token) {
        try {
            String query = "Update TBL_USER set USR_TOKEN ="+token+" where email="+email+" ";
            Connection con = DBConnection.getConnection();
            PreparedStatement statement = con.prepareStatement(query);
            int result = statement.executeUpdate();
            System.out.println("result is: " + result);

        } catch (Exception ex) {
            System.out.println("Error in TokenSaverDAO class");
            ex.printStackTrace();
        }
    }
</code></pre>

<p>But I get an error:</p>

<pre><code>java.sql.SQLSyntaxErrorException: ORA-00972: identifier is too long
</code></pre>

<p>I tried using CLOB as column type but still get the same error.</p>

<p>This is my token:</p>

<pre><code>eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvcnRoLmNvbSIsInN1YiI6IlJUSCIsImV4cCI6MTQ1MzE1NDI2MywiZW1haWwiOiJraXJpdGkuazk5OUBnbWFpbC5jb20ifQ
.X13gGlAIbS3bh-2eX-SdZjglA-QSMW5Gz_IokRdGWXqmmdQDYHNgbKpuqhtf7EqSLN_I8Qx80FMKzVXn9G4O1-bhXCDkWWHkPaC
WN16RJazyJdWqzHHTVHD2AN-mF6eG7KFto5HlvFfIdvgQZszAzqS_cVGQHM1hIn-r5sCrkI4
</code></pre>

<p>Is there any other way to save the token in DB or may be saving it in map for each user who's logged in. If I use map then how do I do the authentication each time user request for a resource.</p>

<p>Right now I am doing this:</p>

<pre><code>@Secured
@Provider
@Priority(Priorities.AUTHENTICATION)
public class AuthenticationFilter implements ContainerRequestFilter {

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
        // Get the HTTP Authorization header from the request
        String authorizationHeader = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);

        // Check if the HTTP Authorization header is present and formatted correctly 
        if (authorizationHeader == null || !authorizationHeader.startsWith("Bearer ")) {
            throw new NotAuthorizedException("Authorization header must be provided");
        }

        // Extract the token from the HTTP Authorization header
        String token = authorizationHeader.substring("Bearer".length()).trim();
        System.out.println("request token is: " + token);

        try {

            // Validate the token
            validateToken(token);

        } catch (Exception e) {
            requestContext.abortWith(
                    Response.status(Response.Status.UNAUTHORIZED).build());
        }
    }

    private void validateToken(String token) throws Exception {
        // Check if the token was issued by the server that is saved in Database and if it's not expired
        // Throw an Exception if the token is invalid
    }
}
</code></pre>

<p>Two questions here:</p>

<ol>
<li>How to fix java.sql.SQLSyntaxErrorException: ORA-00972: identifier is too long</li>
<li>Saving token in map or cache and performing the JWT authentication on
each resource request</li>
</ol>