JDBC submission?
Posted by: Ray Madigan
Date: May 01, 2010 09:09AM

I am having difficulty initializing my application data. In the past on another database I have an ant task that uses JDBC to read and write to the database that puts the dataset in a good starting condition. Actually multiple tasks, but thats not important.

The problem I am having is that there is a significant difference between what happens when I submit some requests with ant/JDBC and when I type them into mysql client, even if the client is on another machine in the network.

The latest issue is

I have a table that has a date column that in other databases I would fill at row insert with a default like;

origin DATE NOT NULL DEFAULT CURRENT_DATE,

since mysql cant fill dates with default date functions I used the following trigger.

origin DATE NOT NULL,

CREATE TRIGGER originPart BEFORE INSERT ON Part
FOR EACH ROW
SET new.origin = now();

if I type in an insert into the mysql client the origin column is filled by the trigger, if I submit the same request with and and jdbc I get the following

/lemur/resource/sommelier/build.xml:90: org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO Part ( partN, zip ) VALUES ( ?, ? )]; SQL state [HY000]; error code [1364]; Field 'origin' doesn't have a default value; nested exception is java.sql.SQLException: Field 'origin' doesn't have a default value

Here is the dataSource properties for the connection. Simple requests work, this is the first one that has a trigger attached.

Properties dataSource = new Properties ( );
dataSource.setProperty ( "auth", "Container" );
dataSource.setProperty ( "type", "javax.sql.DataSource" );
dataSource.setProperty ( "driverClassName", "com.mysql.jdbc.Driver");
dataSource.setProperty ( "url", "jdbc:mysql://192.168.1.30:3306/sommelier");
dataSource.setProperty ( "maxActive", "20" );
dataSource.setProperty ( "maxIdle", "10" );
dataSource.setProperty ( "username", "xxx" );
dataSource.setProperty ( "password", "yyy" );



Edited 2 time(s). Last edit at 05/01/2010 09:46AM by Ray Madigan.

Options: ReplyQuote


Subject
Written By
Posted
JDBC submission?
May 01, 2010 09:09AM
May 03, 2010 09:22AM
July 07, 2010 08:23AM
July 07, 2010 08:29AM
July 08, 2010 08:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.