Trying to run the db2 command using jdbc. Below is java code and exception
db2 load from file of del modified by coldel0x09 insert into item Code:
Connection conn = getConnectionFromDB(); // Connection object
Statement stmt = conn.createStatement(); //Statement object
sql = "db2 load from filepath of del modified by coldel0x09 insert into tablename";//command
System.out.println("Executing command: "+ sql);
stmt.execute(sql);
} catch (SQLException e) {
throw new RuntimeException("Error loading into table '" + tableName + "' with SQL: " + sql, e);
}
}
getting Exception after run the command:
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=load;db2 ;JOIN , DRIVER=4.9.78 at com.ibm.db2.jcc.am.fd.a(fd.java:676) at com.ibm.db2.jcc.am.fd.a(fd.java:60) at com.ibm.db2.jcc.am.fd.a(fd.java:127) at com.ibm.db2.jcc.am.en.c(en.java:2553) at com.ibm.db2.jcc.am.en.d(en.java:2541) at com.ibm.db2.jcc.am.en.b(en.java:1957) at com.ibm.db2.jcc.t4.cb.h(cb.java:221) at com.ibm.db2.jcc.t4.cb.b(cb.java:47) at com.ibm.db2.jcc.t4.q.b(q.java:38) at com.ibm.db2.jcc.t4.rb.h(rb.java:114) at com.ibm.db2.jcc.am.en.hb(en.java:1952) at com.ibm.db2.jcc.am.en.a(en.java:3040) at com.ibm.db2.jcc.am.en.e(en.java:1028) at com.ibm.db2.jcc.am.en.execute(en.java:1012)
EXTERNAL TABLE
to load your data if you are using Db2 11.5. This is an SQL statement and not a command like LOAD ibm.com/support/knowledgecenter/en/SSEPGG_11.5.0/… it can also load remote files, again unlike LOAD – Paul Vernon