java中实现导入txt到oracle

在java中从mysql中导出一千万条数据到txt文档中 ,已经转换为sqlldr所识别的数据,( 以 | 来分隔) 能不能用java实现将txt文档导入到oracle中相对应的表中。需要写成通用组件的。最好不要一条条读取。

第1个回答  2013-08-31
System.out.println("上传文件中……");
FormFile file = billForm.getFile();//取得上传的文件
if (file != null && file.getFileSize() == 0) {// 判断上传数据是否为空
request.setAttribute("msg", "该文件无内容或为空");
InputStream read = file.getInputStream();
String[] sp = null;
int i=0;

BufferedReader reader = new BufferedReader(new InputStreamReader(read));//直接对数据流进行操作/****以下为读取数据并赋值**/
String line;
line = reader.readLine();
CsPosCommercial cp = null;
while (line != null) {
i++;
cp= new CsPosCommercial();
System.out.println(line);
sp = line.split("\\|");
cp.setWtCommerLikename(sp[0]);
cp.getId().setWtCommerMercode(sp[1]);
cp.getId().setWtCommerTrmcode(sp[2]);
cp.setWtAcquirer(sp[3]);
cp.setWtBusTag(Long.valueOf(sp[5]));
cp.setWtState("01");
cp.setWtMnKey(sp[4]);
line = reader.readLine(); // 读取下一行
}
request.setAttribute("msg", "数据导入成功!");
read.close();//关闭数据流
} 自己研究吧
第2个回答  2013-08-31
第3个回答  2013-08-31
这个思路嘛。。接收一个参数:分隔符 或者更好的办法然后 最好不要一条条的读么? 至少我没办法~存进表里 不一条一条读 还能?请指教
第4个回答  2013-08-31
给我把下载文件的代码 能一份用 java 的。。谢谢了
相似回答
大家正在搜