Description:
        I use the MM JDBC driver version 2.0.4 to access my MySQL database from my
Java app.  If I do "SELECT NOW()", it returns a String object and not a Date
object.  I tried to call different functions (e.g. "SELECT DATE_ADD(NOW(),
INTERVAL 0 SECOND)") in order to have a Date in my ResultSet, byt all I get
is a String.

        Also, a query like "SELECT *, NOW() FROM some_table" also returns a String
for the NOW() column and not a Date.

How-To-Repeat:
Here is a sample Java application to demonstrate this...

import java.sql.*;

public class Test
{
    public static void main(String[] pasArgs)
    {
        try
        {
            Connection oConnect;
            Statement  oStmt;
            ResultSet  oRes;

            Class.forName("org.gjt.mm.mysql.Driver");

            oConnect = DriverManager.getConnection
                        ("jdbc:mysql://host:3306/db", "user", "password");

            oStmt = oConnect.createStatement();

            oRes = oStmt.executeQuery("SELECT NOW()");

            oRes.next();

            // This prints java.lang.String and not java.util.Date or
java.sql.Date
            System.out.println(oRes.getObject(1).getClass().toString());

            oRes.close();
            oStmt.close();
            oConnect.close();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

Fix:


Submitter-Id:
Originator:     Super-User
Organization:

MySQL support: [none | licence | email support | extended email support ]
Synopsis:
Severity:
Priority:
Category:       mysql
Class:
Release:        mysql-3.23.40 (Official MySQL binary)

Environment:

System: SunOS centaure 5.8 Generic_108528-06 sun4u sparc SUNW,Sun-Blade-100
Architecture: sun4

Some paths:  /usr/bin/perl /usr/ccs/bin/make /opt/local/bin/gcc /usr/ucb/cc
GCC: Reading specs from
/opt/SISPgcc/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/specs
gcc version 2.8.1
Compilation info: CC='gcc'  CFLAGS='-O3 -fno-omit-frame-pointer'  CXX='gcc'
CXXFLAGS='-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -
fno-rtti'  LDFLAGS=''
LIBC:
-rw-r--r--   1 root     bin      1754016 Nov 23  2000 /lib/libc.a
lrwxrwxrwx   1 root     root          11 Jun 20 23:17 /lib/libc.so -
./libc.so.1
-rwxr-xr-x   1 root     bin      1129948 Nov 23  2000 /lib/libc.so.1
-rw-r--r--   1 root     bin      1754016 Nov 23  2000 /usr/lib/libc.a
lrwxrwxrwx   1 root     root          11 Jun 20 23:17 /usr/lib/libc.so -
./libc.so.1
-rwxr-xr-x   1 root     bin      1129948 Nov 23  2000 /usr/lib/libc.so.1
Configure command: ./configure  --prefix=/usr/local/mysql
'--with-comment=Official MySQL
binary' --with-extra-charsets=complex --with-server-suffix= --enable-assembl
er --disable-shared
Perl: This is perl, version 5.005_03 built for sun4-solaris

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail
To unsubscribe, e-mail
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to