Re: jdbc: values from mysql table always null

Todd Farmer <[email protected]> Mon, 12 Dec 2011 11:05:24 -0800
Newsgroups gmane.comp.db.mysql.java
Organization Oracle Corporation
Message-ID <[email protected]>
Hey Ryan,

On 12/12/2011 9:35 AM, Ryan Beckes wrote:
> I am trying to copy one table to another using jdbc (see code below). The
> table is copied fine, but the last column is NULL for all values. I am also
> having problems retrieving the value from that table (the value is always
> returned as null). If I run the same sql commands via the mysql client, the
> table is copied OK.

You say that the same exact commands executed in the CLI work fine and 
produce different results than when executed from the JDBC client 
application.  If that's the case, the most probably root cause is SQL 
Mode (for JDBC compliance, Connector/J sets SQL Mode to 
"strict_trans_tables").  The various SQL modes are described here:

http://dev.mysql.com/doc/refman/5.5/en/server-sql-mode.html

The fastest way to see exactly what's happening is to turn on the MySQL 
Server general query log, and issue the same statements from both the 
CLI and the JDBC application.  This will log the statements before they 
are executed - including statements to set the SQL Mode - and should 
help confirm exactly what the server is receiving from the JDBC application.

Best regards,

-- 
Todd Farmer


-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/java