| Author |
Problem inserting a null date into a MDB
|
mutyalarao aripaka
Greenhorn
Joined: Nov 09, 2006
Posts: 6
|
|
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?
|
Regards<br />Mutyala Rao Aripaka<br />Bangalore, INDIA
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26182
|
|
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.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
mutyalarao aripaka
Greenhorn
Joined: Nov 09, 2006
Posts: 6
|
|
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?
|
 |
 |
|
|
subject: Problem inserting a null date into a MDB
|
|
|