Article View: borland.public.jbuilder.database
Article #313Re: default values problem with mysql version 5
From: Paul Nichols [TeamB]
Date: Sun, 19 Aug 2007 06:45
Date: Sun, 19 Aug 2007 06:45
49 lines
2687 bytes
2687 bytes
Anton Jungreuthmayer wrote:
> Paul Nichols [TeamB] wrote:
>> Anton Jungreuthmayer wrote:
>>> I have an application written in java with jBuilder.
>>>
>>> This uses JDBC to access a mySQL database which I am converting from
>>> version 4.1 to version 5.0
>>>
>>> When my application tries to INSERT a record but does not specify a
>>> value for a text field that is defined as NOT NULL with no default
>>> set the following error message is returned :
>>>
>>> Field 'somedata' doesn't have a default value
>>>
>>> this doesn't happen with JDBC on mysql 4.1
>>> It also doesn't happen when I run the command in mysql, or when using
>>> mySql query browser but only when I connect using JDBC
>>>
>>> Any clues ?
>>>
>>> Anton
>>
>> This is not going to be related to JB, unless you are using the
>> QueryDataSet, which may or may not work correctly with newer JDBC
>> implementations.
>>
>
> JDBC driver - 5.0.6
> java version 1.5.0_04-b05
Thanks for this info. The problem has to do with a commit error with V5
and the newer mySQL database transaction mechanism. It is a bug and has
been reported.
To get around this issue try setting jdbcCompliantTruncation=false. This
will prevent the exception from being thrown before it gets to the MySQL
Server.
See example below:
Class.forName("com.mysql.jdbc.Driver");
String dburl = "jdbc:mysql://server/TEST";
String dburlTrunc =
"jdbc:mysql://server/TEST?jdbcCompliantTruncation=false";
String dbuser = "TEST";
String dbpass = "TEST";
Connection connection = DriverManager.getConnection(dburl, dbuser,
dbpass);
Technical Details
Message-ID:
<46c7e6f4@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46c5bbd4@newsgroups.borland.com> <46c5c2b8@newsgroups.borland.com> <46c5c3ec$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1073da,46beccc389838db9 X-Google-Attributes: gid1073da,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Sun, 19 Aug 2007 02:45:09 -0400 From: "Paul Nichols [TeamB]" <paul@none.com> User-Agent: Thunderbird 1.5.0.12 (X11/20070604) MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.database Subject: Re: default values problem with mysql version 5 References: <46c5bbd4@newsgroups.borland.com> <46c5c2b8@newsgroups.borland.com> <46c5c3ec$1@newsgroups.borland.com> In-Reply-To: <46c5c3ec$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 76.97.213.175 Message-ID: <46c7e6f4@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1187505908 76.97.213.175 (18 Aug 2007 23:45:08 -0700) Lines: 49 Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail