1

I have a serializable class that extends Servlet

public class FileDownload extends HttpServlet{
  @SuppressWarnings("compatibility:6754389671327954013")
  private static final long serialVersionUID = 1L;
  private ResultSet rset;
  ......
}

My Question is:

Is the rset object automatically converted as transient at compile- or run-time? or do I have to mark it explicitly as transient? (That is a warning brought up from my IDE JDeveloper).

2
  • 1
    OTOH, why would you store a ResultSet in a servlet? Commented Jul 5, 2012 at 14:29
  • educational kind o question :) it could be any other type of Object Commented Jul 5, 2012 at 14:30

2 Answers 2

2

No, the field is not neglected by serialization - you'll get a java.io.NotSerializableException if you try to serialize an instance of FileDownload. Mark it transient. Btw, what is a ResultSet doing as a field in a Servlet? This is not thread-safe. ResultSets should be local variables only, in any context.

Sign up to request clarification or add additional context in comments.

Comments

0

You have to call transient your own.But you cannot serialize an object unless it implements Serializable interface.ResultSet is such kind of object.

1 Comment

First sentence is meaningless. Second is incorrect: ResultSet isn't an object at all, it is an interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.