version: 9.1 create table problem with multiple timestamp fields
a
anonymous
started a topic
about 11 years ago
[This topic is migrated from our old forums. The original author name has been removed]
Hello,
This works on PHPMyAdmin:
CREATE TABLE t1 (
ts1 TIMESTAMP DEFAULT 0,
ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP);
This creates a table which inserts current_timestamp to field ts1 when a null value is given in insert statement. (This is new to me, but looks very useful.)
I wasn't able to create the table with this definition using the create table wizard in dbV.
When I view the table in dbV, the ts1 field is pink and shows "error":
Error getting value for: 1/2: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
Do I need to install the java7 version?
version details:
Product: DbVisualizer Pro 9.1
Build: #2050 (2013/09/08 11:03)
Java VM: Java HotSpot(TM) 64-Bit Server VM
Java Version: 1.6.0_51
Java Vendor: Apple Inc.
OS Name: Mac OS X
OS Arch: x86_64
OS Version: 10.8.4
Thanks.
Julie
Re: version: 9.1 create table problem with multiple timestamp fields
Hi Julie,
I believe this actually sets ts1 to 0 when null is passed, and by default, 0 cannot be converted to a Timestamp in Java. You can change this by setting the zeroDateTimeBehavior driver property for the connection to convertToNull in the Properties tab for the connection:
http://confluence.dbvis.com/display/UG91/Configuring+Connection+Properties
If you want it to be set to current_timestamp, you should use the syntax you have for the tsp column.
Best Regards,
Hans
a
anonymous
said
about 11 years ago
[This reply is migrated from our old forums. The original author name has been removed]
Re: version: 9.1 create table problem with multiple timestamp fields
Thanks so much. That did the trick. I appreciate your fast response.
Julie
anonymous