• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

setting the null and getting null  RSS feed

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai,
sorry, iam not clear about the answer

i created a table as

sno number(5)
sname varchar2(15)

PreparedStatement pst=con.prepareStatement("insert into mytab values(?,?)");
pst.setNull(1,Types.NULL); //invalid column name
pst.setString(2,"john");
pst.executeUpdate();

when i execute the above program it is giving the invalid column name
error at run time.

please solve my query.
and how to getNull value form table..
bye
 
Ranch Hand
Posts: 1085
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by yathamshetti ramchander:
sorry, iam not clear about the answer


Seems it is continuation of other thread

Make your PreparedStatement as


PreparedStatement pst=con.prepareStatement("insert into mytab(sno,sname ) values(?,?)");



Thanks,
Shailesh
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Yathamshetti ramchander ,

change your code and work it out

PreparedStatement pst=con.prepareStatement("insert into <<tablename>> values(?,?)");
pst.setNull(1,java.sql.Types.INTEGER); //invalid column name
pst.setString(2,"john");
pst.executeUpdate();


example can be view in :

http://www.java2s.com/Code/Java/Database-SQL-JDBC/DemoPreparedStatementSetNullforintvaluecolumn.htm



by
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!