This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes Problem inserting a null date into a MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem inserting a null date into a MDB" Watch "Problem inserting a null date into a MDB" New topic
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: 30352
    
150

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem inserting a null date into a MDB