Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / November 2006

Tip: Looking for answers? Try searching our database.

MySQL, boolean and BIT datatypes

Thread view: 
Jeff - 15 Nov 2006 19:35 GMT
Using MySQL 5.0.22, Connector/J 3.12. I have datafields defined as
BIT(1) type, which is supposed to map to java Boolean, which is great
because I am displaying resultset in a jTable and I want the BIT fields
displayed as checkboxes. Displaying data from the resultset is fine.
The problem is with updating the BIT fields. Here is the relevant
portion of the routine: (war_rs is a ResultSet, bleedingCB and
changeMedsCB  are checkboxes - the error I get is a data truncation
because BleedingProbs is too large when the insertRow() is executed).

       try {
           war_rs.moveToInsertRow();
           war_rs.updateString("ID",theID);
           war_rs.updateString("Date",dateFld.getText());
           war_rs.updateString("OldDose",oldDoseFld.getText());
           war_rs.updateString("PT",ptFld.getText());
           war_rs.updateString("INR",inrFld.getText());
           war_rs.updateString("Control",controlFld.getText());

war_rs.updateBoolean("BleedingProbs",bleedingCB.isSelected()); //This
is the field flagged as data truncated

war_rs.updateBoolean("ChangeInMeds",changeMedsCB.isSelected());
           war_rs.updateString("Comment",commentFld.getText());

war_rs.updateString("EntryBy",conn.getMetaData().getUserName());
           war_rs.insertRow(); // This is the line that actually
generates the error.
           updateID(theID);
       } catch (SQLException e) {
           e.printStackTrace();
       }
Nobody - 18 Nov 2006 21:35 GMT
>Using MySQL 5.0.22, Connector/J 3.12. I have datafields defined as
>BIT(1) type, which is supposed to map to java Boolean, which is great
[quoted text clipped - 4 lines]
>changeMedsCB  are checkboxes - the error I get is a data truncation
>because BleedingProbs is too large when the insertRow() is executed).

I didn't look at your code but try again with Connector/J 3.1.14. They
fixed a JDBC driver bug for us in that version that was causing data
truncation errors on updates of certain fields. You're likely to get
more help if you post this on the forums at www.MySQL.com

BA


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.