[Qt-jambi-interest] DB query bug?

Derek Fountain derekfountain at yahoo.co.uk
Wed Aug 19 18:35:11 CEST 2009


If I run this query from a MySQL browser:

select sec_to_time( time_to_sec(30) )

I get:

00:00:30

as expected.

But if I bundle it up and run it from QtJambi with this:

package mypackage;

import com.trolltech.qt.sql.*;

public class TestQuery {

     public static void main(String[] args)
     {
         QJdbc.initialize();

         try {
             Class.forName("com.mysql.jdbc.Driver").newInstance();
         } catch (Exception ex) { System.err.println(ex); return; }

         QSqlDatabase db = QSqlDatabase.addDatabase("QJDBC");
         db.setDatabaseName("jdbc:mysql://localhost/myproject");
         db.setUserName("root");
         db.setPassword("");
         if (db.open() == false) {
             System.out.println("Connection Failed!");
             return;
         }

         QSqlQuery query = new QSqlQuery(db);
         query.prepare( "select sec_to_time( time_to_sec(30) )" );
         if ( query.exec() == false )
         {
             System.out.println("Query barfed");
             return;
         }
         query.next();

         System.out.println(query.value( 0 ));
     }

}

it returns:

00:01:30

Why would that be?



More information about the Qt-jambi-interest mailing list