473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

strict_trans_tables and null defaults

I am using 5.0.21 community-nt and have the following in the
configuration file:

transaction-isolation=READ-COMMITTED
sql-mode=ansi,strict_trans_tables

I have defined this little table:

create table my_table
(id int not null primary key auto_increment,
some_text varchar(20) not null,
other_text varchar(20) default 'aaa') type=innodb

Then I try this insert:

insert into my_table (other_text) values ('abc');

I get an error 1364(HY000) Field 'some_text' doesn't have a default
value.

Great, this is what I expected.... Life is good, so far.
Now, if I try to get the table metadata using JConnector 3.1.13 I get
some unexplicable results.

Here's the program
public class SomeTest
{
private static final String tableTypes[] =
{ "TABLE", "VIEW", "SYSTEM TABLE" };

public static void main(String[] args) throws Exception
{
Connection conn;
Statement stmt;
ResultSet rs;
String[] columnNames;

Class.forName("com.mysql.jdbc.Driver").newInstance ();
conn =
DriverManager.getConnection(
"jdbc:mysql://localhost:3306/mydb",
"myuser",
"mypassword");

DatabaseMetaData metadata = conn.getMetaData();
stmt = conn.createStatement();
rs = metadata.getColumns(null,null,"my_table","%");
ResultSetMetaData resultMetadata = rs.getMetaData();
int columnCount = resultMetadata.getColumnCount();
columnNames = new String[columnCount];
for (int i = 1; i <= columnCount; i++)
{
columnNames[i - 1] = resultMetadata.getColumnName(i);
System.out.print(columnNames[i - 1]);
if (i < columnCount)
{
System.out.print(",");
}
}
System.out.println();
while (rs.next())
{
for (int i = 1; i <= columnCount; i++)
{
System.out.print("\"" + rs.getString(columnNames[i - 1]) + "\"");
if (i < columnCount)
{
System.out.print(",");
}
}
System.out.println();
}
rs.close();
stmt.close();
conn.close();
}
}
Here's what I get...

TABLE_CAT,TABLE_SCHEM,TABLE_NAME,COLUMN_NAME,DATA_ TYPE,TYPE_NAME,COLUMN_SIZE,BUFFER_LENGTH,DECIMAL_D IGITS,NUM_PREC_RADIX,NULLABLE,REMARKS,COLUMN_DEF,S QL_DATA_TYPE,SQL_DATETIME_SUB,CHAR_OCTET_LENGTH,OR DINAL_POSITION,IS_NULLABLE
"null","null","my_table","id","4","int","11","6553 5","0","10","0","","null","0","0","11","1","NO"
"null","null","my_table","some_text","12","varchar ","20","65535","0","10","0","","","0","0","20","2" ,"NO"
"null","null","my_table","other_text","12","varcha r","20","65535","0","10","1","","aaa","0","0","20" ,"3","YES"

Looking at the field 'some_text', JConnector tells me that it has a
default of empty string instead of null which would be what the insert
statement would indicate.

I understand the reasoning behind assigning a 'default' value to every
field when none was specified in order not to break MyISAM
'transactions'...

My question is
Can this functionality be changed for strct_trans_tables (perhaps
strict_all_tables as well) so that it really returns a NULL default?

Axel

Jul 17 '06 #1
0 3378

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kris M | last post by:
How do i handle a null value for a date variable type. I am retrieving date data from an access database and storing the records in an array for processing. The array field has a date type and the...
1
by: Jamie Burns | last post by:
Hello, I am trying to perform a LEFT JOIN on a table which may or may not have matching rows. If there are no matching rows, it returns NULL's for all the missing fields. Is there anyway of...
3
by: iStrain | last post by:
Hiya. I'm _sure_ this is an FAQ, but Googling hasn't produced the answer in a way I can make sense out of. I know I should get this, but so far no way... I'm creating tables and doing queries in...
19
by: Baldur Norddahl | last post by:
Hi, How come "X=null" is not the same as "X is null"? I got a few selects with queries like this: select * from foo where customer=#customer# or (#customer# is null and customer is null) ...
2
by: zeljko.prince | last post by:
This is a copy from http://forums.mysql.com/read.php?10,73797,73797#msg-73797. Perhaps someone on this group will know the answer. Given the following table: CREATE TABLE foo(field VARCHAR(20)...
2
by: clickon | last post by:
I am using ASP.net 2.0 and trying to take advantage of the updated data editing facilities provided through the SQLDataSource control and the DetailsView control. The data is a record from a...
6
by: axelsino | last post by:
I know this has been asked before and yes, I have read the section in the documentation about it. But, my question is: If I have setup mysql with strict_trans_tables, will MySQL allow "null"...
26
by: ryampolsky | last post by:
I'm using strtok to break apart a colon-delimited string. It basically works, but it looks like strtok skips over empty sections. In other words, if the string has 2 colons in a row, it doesn't...
1
by: janetopps | last post by:
I used a database transfer utility (Bullzip) to move data from Access to MySQL Asp pages, I couldn't transfer the data if i did not opt to leave the default values, therefore the default values...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.