Hi,

I am having problems with inserting datetime values to a datatable. I
am reading the data from a MySQL database. If I set all columns to
type TEXT then this works.

I'm trying to populate a DataTable that has the following columns:

    DataTable data = new DataTable();
    ArrayList<ColumnDescription> cd = new
ArrayList<ColumnDescription>();
    cd.add(new ColumnDescription("Aika", ValueType.DATETIME, "Aika"));
    cd.add(new ColumnDescription("Menovesi", ValueType.TEXT,
"Menovesi"));
    cd.add(new ColumnDescription("Paluuvesi", ValueType.TEXT,
"Paluuvesi"));
    cd.add(new ColumnDescription("Ulkolampo", ValueType.TEXT,
"Ulkolampotila"));
    cd.add(new ColumnDescription("Huone", ValueType.TEXT,
"Sisälampotila"));
    data.addColumns(cd);

Then I get the data from DB

        DateTimeValue dt = null;
        while (rs.next()) {
                Integer vuosi = rs.getInt("year");
                Integer kuukausi = rs.getInt("month");
                Integer paiva = rs.getInt("day");
                Integer tunti = rs.getInt("hour");
                Integer minuutti = rs.getInt("minute");

                dt = new
DateTimeValue(vuosi,kuukausi,paiva,tunti,minuutti, 0, 0);

                float menovesi = rs.getString("menovesi");
                String paluuvesi = rs.getString("paluuvesi");
                String ulkolampo = rs.getString("ulkolampo");
                String huone = rs.getString("huone");

                try {
 
data.addRowFromValues(dt,menovesi,paluuvesi,ulkolampo,huone);
                }
                  catch (TypeMismatchException e) {
                  System.out.println("Invalid type!");
                }


This results in the "Invalid Type" exception (Type mismatch error).
The problem is with the first column "Aika".
As far as I can see it this should be inserting a datetime value to a
datetime cell ??

Can someone tell me where I am going wrong ?

br,
Sami

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to