Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem inserting a null date into a MDB

 
mutyalarao aripaka
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i am a novice to java I was trying connecting to access mdb file using jdbc. I created a table EMP which had three fields - name(text),descritpion(text),date(date/tim of which name field in which name is primary. I saved the mdb as testmdb.mdb ad had create the system DSN to it.

I had tried to insert a new record with "test" name using my program. Below is an excerpt from my program which i think is causing the problem.

when i am running this program is throwing an error message in the console that there was s data type mismatch in the expression criteria.

i had tried modifying the statement execute line as:
s.execute("insert into emp values 'test','','10-nov-2006'");

it worked and i was able to see the record added when i had opened the mdb. I had double checked that the date field was not made as required. Where else can be the problem?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mutyala,
Welcome to JavaRanch!

As you've noticed '' is not the same as null. One way to specify a null is to leave it out. For example:
s.execute("insert into emp (col_name) values ('test')");

This will set col_name to 'test' and leave the other two unspecified columns as null.
 
mutyalarao aripaka
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

thnx for the reply.
1.what if i have to store the date as input given by the user(that can be optional)?

2. how to insert system date into it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic