Re: Accessing a protected variable of PreparedStatement
- From: Daniel Pitts <googlegroupie@xxxxxxxxxxxxx>
- Date: 30 Apr 2007 10:30:26 -0700
On Apr 30, 8:51 am, Gello Ramello <gabri...@xxxxxxxxxxxx> wrote:
Hi, the environment is Java 1.5, Tomcat 5.5, Postgres 8.1, EclipseFirst, Debuggers have special access.
3.1.1 and Windows XP Pro.
I want to create a function that reads PreparedStatement attributes.
The ps is passed as generic object function parameter and then casted
to PreparedStatement. I can access to PreparedMetaData and other
stuffs, but not to the _stmt properties and methods (like QueryString,
query parameters etc). In fact _stmt is a protected property of
PreparedStatement. My question is: why, as seen in debug mode, Eclipse
can access it and all its methods and properties?
How can I access to _stmt?
Thank you.
Second, you can use reflection to access protected properties.
Third, Don't use reflection to access protected properties...
Generally, even if the PreparedStatement has a string property which
holds the "statement", it is actually just a place-holder reference
for a statement that is already compiled on your SQL server. Changing
the stmt at best would have no effect, and at worse would cause
undefined behavior. Its a bad idea to violate access constraints,
even if you are able.
.
- Follow-Ups:
- Re: Accessing a protected variable of PreparedStatement
- From: Gello Ramello
- Re: Accessing a protected variable of PreparedStatement
- References:
- Accessing a protected variable of PreparedStatement
- From: Gello Ramello
- Accessing a protected variable of PreparedStatement
- Prev by Date: Re: Annotations and generic programming
- Next by Date: Re: Java (bytecode) execution speed
- Previous by thread: Accessing a protected variable of PreparedStatement
- Next by thread: Re: Accessing a protected variable of PreparedStatement
- Index(es):