怎么使用Vert.x将Blob插入Oracle数据库11g?
原学程将引见若何应用Vert.x将Blob拔出Oracle数据库一一g?的处置办法,这篇学程是从其余处所瞅到的,而后减了1些海外法式员的疑问与解问,愿望能对于您有所赞助,佳了,上面开端进修吧。
成绩描写
我正在测验考试应用vert.x将BLOB拔出Oracle数据库,我获得了上载文件
for (FileUpload f : routingContext.fileUploads()){
System.out.println("file name " + f.fileName());
System.out.println("size name " + f.size());
System.out.println("Uploaded File " + f.uploadedFileName());
}
我应用以下敕令将FileUpload转换为字节数组:
Buffer fileUploaded = routingContext.vertx().fileSystem().readFileBlocking(f.uploadedFileName());
byte[] fileUploadedBytes = fileUploaded.getBytes();
如今我想将其直交拔出Oracle数据库,我曾经测验考试应用updateWithParams
,但是我没有晓得怎样将Blob添减到盘问参数中。
感激您的赞助
推举谜底
这是我的完成去处理我的成绩,如今我不妨将文件BLOB拔出到ORACLE数据库中,我愿望这能在将来对于或人有所赞助。
ByteArrayInputStream finalBis = bis;
byte[] finalFileUploadedBytes = fileUploadedBytes;
DB.getConnection(connection -> {
if (connection.succeeded()) {
CallableStatement stmt = null;
try {
stmt = connection.result().getConnection().prepareCall(SQL.INSERT_DOCS_QUERY);
stmt.setBinaryStream(一, finalBis, finalFileUploadedBytes.length);
stmt.setString(二,desiDoc);
stmt.setString(三,sourDoc);
logger.debug(stmt);
stmt.execute();
finalBis.close();
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
System.out.println("nooot ok");
}
});
佳了闭于怎样应用Vert.x将Blob拔出Oracle数据库一一g?的学程便到这里便停止了,愿望趣模板源码网找到的这篇技巧文章能赞助到年夜野,更多技巧学程不妨在站内搜刮。