I tried node-jt400 (IFS write)

IFS write This is the end of the coding example.


var jt400 = require("node-jt400");
var express = require("express");
var iconv = require('iconv-lite');
var app = express();

var pool = jt400.pool({ host: '192.168.X.XXX', user: 'MYUSER', password: 'MYPASS' });

var server = app.listen(8888, function () {
  console.log("curl http://localhost:" + server.address().port + '/~');

app.get("/ifsWrite", function (req, res, next) {
    var sqlReadableStream = pool.createReadStream("select * from member");
    var ifs = pool.ifs();
    var writer = ifs.createWriteStream("/myIfsFolder/node-write.txt", { append: true });
    var buffer = "";
    sqlReadableStream.on("data", function (chunk) {
        buffer += chunk;
    sqlReadableStream.on('end', function () {
        writer.write(iconv.encode(buffer, "UTF-8"));
        res.send(iconv.encode(buffer, "UTF-8"));

I wrote the SQL result to IFS.


I returned the characters correctly to the console, but the characters were garbled in the IFS file.


Java source modification of node-jt400 (corresponding to garbled characters)

The source to be modified is \ java \ src \ nodejt400 \ IfsWriteStream.java. On line 29 is the following code.


fos = new IFSFileOutputStream(file, IFSFileOutputStream.SHARE_ALL, append);

Specify the code page. (This time UTF-8)


fos = new IFSFileOutputStream(file, IFSFileOutputStream.SHARE_ALL, append, 1208);

If the build is successful, replace jt400wrap.jar and try again.


It would be nice if it could be parameterized, but I don't have that much knowledge yet ...

The poster does not take any responsibility for the source modification. Please do so at your own risk.

Added on December 28, 2017 I put the pre-built jt400wrap.jar in here.

Recommended Posts

I tried node-jt400 (IFS write)
I tried node-jt400 (IFS read)
I tried node-jt400 (Programs)
I tried node-jt400 (execute)
I tried node-jt400 (Transactions)
I tried node-jt400 (Environment construction)
I tried node-jt400 (SQL Update)
I tried node-jt400 (SQL query)
I tried node-jt400 (SQL stream)
I tried Spring.
I tried tomcat
I tried youtubeDataApi.
I tried refactoring ①
I tried FizzBuzz.
I tried JHipster 5.1
[I tried] Spring tutorial
I tried running Autoware
I tried using Gson
I tried QUARKUS immediately
I tried using TestNG
I tried Spring Batch
I tried using Galasa
I tried DI with Ruby
I tried using azure cloud-init
I tried Spring State machine
I tried Drools (Java, InputStream)
I tried Rails beginner [Chapter 1]
I tried the Docker tutorial!
I tried using Apache Wicket
I tried the VueJS tutorial!
I tried using Java REPL
I tried source code analysis
I tried the FizzBuzz problem
I tried putting XcodeGen + SwiftPM
I tried Rails beginner [Chapter 2]
I tried UPSERT with PostgreSQL.
I tried BIND with Docker
I tried to verify yum-cron
I tried Jets (ruby serverless)
I tried metaprogramming in Java
I tried to write code like a type declaration in Ruby
I tried using anakia + Jing now
I tried Angular tutorial + SpringBoot + PostgreSQL
I tried to chew C # (indexer)
I tried something called recursive search
I tried using Spring + Mybatis + DbUnit
I tried using JOOQ with Gradle
[K8s] I tried communication between pods!
I tried morphological analysis with MeCab
I tried a little digdag docker.run_options
I tried to summarize iOS 14 support
I tried to interact with Java
I tried UDP communication with Java
I tried to explain the method
I tried putting Domino11 in CentOS7
I tried the Java framework "Quarkus"
[Rails] I tried deleting the application
I tried using Java8 Stream API
I tried Java's micro-benchmark tool JMH
I tried using JWT in Java
I tried GraphQL with Spring Boot