Hello.
If I call :
String myStr = myStatement.getString(1);
I get "null" (literaly 4 chars) in myStr if the value of the retrieved data is null. I try this:
String myStr = ""+myStatement.getString(1);
but the problem remains since literal "null" string is returned by the statement object.
Have you got an idea on how to solve it? I would like retrieving the null value but not the "null" string.
I use Sun's j2ee reference implementation 1.2.1 + jdk1.2
Thanks!
J. Carlos Muro
-
Cannot retrieve null String from a PreparedStatement. (2 messages)
- Posted by: Juan Carlos Muro
- Posted on: May 14 2002 09:36 EDT
Threaded Messages (2)
- Cannot retrieve null String from a PreparedStatement. by Randy Poznan on May 14 2002 17:08 EDT
- Cannot retrieve null String from a PreparedStatement. by Shiva Paranandi on May 14 2002 17:23 EDT
-
Cannot retrieve null String from a PreparedStatement.[ Go to top ]
- Posted by: Randy Poznan
- Posted on: May 14 2002 17:08 EDT
- in response to Juan Carlos Muro
First off be sure that the field in the Table/row you are querying does not actually contain "null" in that column.
Its quite common if you did an insert from somewhere in your Java class via JDBC that upon String conversion of the query the null was evaluated as "null". Use a vendors tool to look at the row in question and verify the value.
I would seriously doubt that the JDBC driver has the bug because most low level protocols would send back some sort of string length indicator. But who knows for sure. -
Cannot retrieve null String from a PreparedStatement.[ Go to top ]
- Posted by: Shiva Paranandi
- Posted on: May 14 2002 17:23 EDT
- in response to Juan Carlos Muro
Your problem is with this statement.
String myStr = ""+myStatement.getString(1);
The driver returns a null object but you are converting it explicitly to "null" string.
statement.getString(int) returns a string. remove the double quotes from the beginning.
Shiva.