• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Types.OTHER confusion

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a Preparedstatement with a single ? in it.
For that ? I am doing a
"setNull(j,Types.OTHER);"
It throws me a exception at this line saying
"cannot Insert NULL......."
The table col in the db is of type varchar2 and does not have a NOT NULL
constraint on it.
Now if I change this line to
setNull(j,Types.VARCHAR);
then it passes properly.
Why is it so?
What is it about Types.OTHER that prevents me from setting it to NULL.
I am using Oracle 9i as the backend db.
Thanks,
Chinmay
 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When using the "setNull(...)" method on a PreparedStatement instance, you need to make sure that the type you send in as the second parameter matches the column type in Oracle. In the Oracle documentation (I looked in the 9i PDF from Oracle) they list the datatype mappings, and nowhere on the list do I see "java.sql.Types.OTHER. This may mean it is not supported in Oracle.
But in any case, if the underlying Oracle column is "varchar2", then you most certainly need to use something like "java.sql.Types.VARCHAR" as the second parameter of your "setNull(...)" call.
If you tried to use "java.sql.Types.INT" or "java.sql.Types.TIMESTAMP" in place of "java.sql.Types.OTHER" you'd probably get the same error. The types have to match.
 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Wayne,
Things are more clearer.
Can u give me the link to the PDF you referred.....??
Thanks again,
Chinmay
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic