Subject: RE: Can Notes trigger a MVS batch job?
Robert,
Why do you need to reformat the Excel file? You can store it as is in DB2 as a BLOB (binary large object). I use a Java agent that employs JDBC to store PDF files in a column of a table in a MS SQL Server database.
Your connectivity to DB2 will differ, but here is a snippet of code from my agent which should give you a sense of what is involved. It’s not a lot of code, it’s just tricky when you’re dealing with Java!
String query = “”;
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Agent agent = agentContext.getCurrentAgent();
Database db = agentContext.getCurrentDatabase();
Document doc = db.getDocumentByID(agent.getParameterDocID()); // NoteID passed to agent can be obtained in ParameterDocID property.
// Establish connection to SQL Server.
Connection con =
// Create a folder object using PATHNAMEPDF field in Notes doc.
File pathPDF = new File(doc.getItemValueString(“PATHNAMEPDF”));
// Get list of files in pathPDF folder object.
String filesPDF = pathPDF.list();
for (int i=0; i < filesPDF.length; i++) {
File pdfFile = new File(doc.getItemValueString(“PATHNAMEPDF”) + filesPDF[i]);
// ? in query below will be replaced by pdfFile object.
query = “INSERT INTO cust_acct_stmts(customer_id, process_date, batch_id, pdf)” +
“VALUES ('” + customerID + “', '” + processDate + “', '” + batchID + “', ?)”;
PreparedStatement pstmt = con.prepareStatement(query);
int fileLength = (int)pdfFile.length();
InputStream in = new FileInputStream(pdfFile);
pstmt.setBinaryStream(1, in, fileLength);
pstmt.executeUpdate();
in.close();
}
Good luck!
Ken