• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!