Ms Sql server field DATETIME with JDBC_getCol

Scott Klement's open source interface to using JDBC database drivers from RPG. http://www.scottklement.com/jdbc/
Post Reply
alessandrotoninelli
Posts: 1
Joined: Thu Feb 15, 2024 9:05 am

Ms Sql server field DATETIME with JDBC_getCol

Post by alessandrotoninelli »

accessing ms sql server with jdbcr4. I do a JDBC_ExecQry which returns the resultSet. iterating on the resultSet to the column that we will call "TIME" of type DATETIME the function JDBC_GetColC(rs:num_col) returns only the date part and not the time.

Example:
the column contains the data: 2014-01-22 08:40:52.500,

fieldTIME = JDBC_GetColC(rs:1) returns me only 2014-01-22


This the code:

Code: Select all


      enval = '/home/alext/java/jdbc/mssql-jdbc-12.6.0.jre8.jar';


       putenv('CLASSPATH='+enval:qusec);

       prop = JDBC_Properties();
       JDBC_setProp(prop: 'user'     : 'user');
       JDBC_setProp(prop: 'password'     : 'password');
       JDBC_setProp(prop: 'database' : 'dbMhs0997');
       JDBC_setProp(prop: 'encrypt' : 'false');
       JDBC_setProp(prop: 'trustServerCertificate' : 'false');

       conn = JDBC_ConnProp(
      'com.microsoft.sqlserver.jdbc.SQLServerDriver'
                             :'jdbc:sqlserver://192.168.0.20:50690'
                             : prop );
       JDBC_freeProp(prop);

       if (conn = *NULL);
           snd-msg 'Not connected';
           return;
       endif;

       monitor;

          rs = JDBC_ExecQry(conn:'SELECT top 1 * FROM dtLu');

          if rs = *null;
             JDBC_close(conn);
             return;
          endif;


          dow JDBC_NextRow(rs);

            fieldTIME = JDBC_GetColC(rs:1);

            snd-msg 'field: '+fieldRs;

          enddo;

          JDBC_FreeResult(rs);

       on-error;

          JDBC_close(conn);

          return;

       endmon;

       JDBC_close(conn);

       return;                       

i used both mssql-jdbc-12.6.0.jre8.jar and jtds-1.3.1.jar
Post Reply