- 浏览: 386784 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (213)
- 面试题目 (9)
- 设计模式 (7)
- Core Java (28)
- 杂记 (10)
- 代码模板 (6)
- 数据库 (6)
- oracle plsql (2)
- strut2 study note (1)
- Oracle Database 10g SQL开发指南学习笔记 (7)
- Unix.Shell编程(第三版) 学习笔记 (1)
- Servlet (1)
- Hibernate (1)
- 敏捷开发 (1)
- Linux (13)
- Velocity (1)
- webx (1)
- Svn (2)
- 页面html,css (2)
- English (4)
- Astah usage (1)
- UML与设计思考 (2)
- JavaScript (3)
- 读书 (4)
- 好的网址 (1)
- 网址 (0)
- JMS (1)
- 持续集成环境 (1)
- 生活 (1)
- Spring (3)
- Tomcat Server (1)
- MySQL (2)
- 算法与数据结构 (6)
- Oracle数据库 (1)
- 分布式计算 (1)
- Maven (1)
- XML (2)
- Perl (2)
- 游戏 (1)
最新评论
-
chen_yi_ping:
请问楼主,怎么测试?String filePath = arg ...
使用多线程模拟多用户并发访问一个或多个tomcat,测试性能 -
adam_zs:
好,谢谢分享。
ArrayDeque实现Stack的功能 -
zjfgf:
int.class==Integer.class 返回fals ...
Class study -
kimmking:
xslt太难写的。
在java中调用xls格式化xml
http://www.javabulls.com/node/1
public class CSVLoader {
public void execute(LoadableCSV csv) throws Exception{
try {
String comand = init(csv);
service(comand);
} catch (Throwable e) {
throw new Exception(e);
} finally {
shutdown();
}
}
protected String init(LoadableCSV csv) {
StringBuffer command = new StringBuffer();
command.append("sqlldr").append(" ");
command.append(csv.getLoaderCommand());
System.out.println("CSVLoader initialized.");
return command.toString();
}
protected void service(String command) throws Exception {
Runtime r = Runtime.getRuntime();
long startTime = System.currentTimeMillis();
try {
Process process = r.exec(command);
if (process == null) {
System.out.println("Process NOT Initialized for command [" + command + "]");
} else {
// wait for the process to exit
process.waitFor();
System.out.println("Loading completed. Exit Value [" + process.exitValue() + "] Time taken ["
+ (System.currentTimeMillis() - startTime) / 1000 + "] sec");
StringBuffer strBuffer = new StringBuffer();
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = reader.readLine()) != null) {
strBuffer.append(line).append("\n");
}
reader.close();
if (process.exitValue() != 0) {
System.out.println("ERROR:" + strBuffer.toString());
throw new Exception("Sql Loading Exited with [" + process.exitValue() + "]");
} else {
System.out.println("Loader completed execution. \n" + strBuffer.toString());
}
}
} catch (InterruptedException e) {
System.out.println("Exception while waiting for process [" + command + "] to complete");
throw e;
} catch (IOException e) {
System.out.println("Exception executing process [" + command + "]");
}
System.out.println("CSVLoader service done.");
}
protected void shutdown() {
System.out.println("CSVLoader shutdown.");
}
}
The Loader class is invoked from any Java process using a LoadableCSV instance.
LoadableCSV is an interface which can be implemented for different flat files
as per the requirement.
public interface LoadableCSV {
public int getRecordsToSkip();
public int getRecordsToLoad();
public int getErrorsAllowed();
public String getSeparator();
public String getLoaderCommand();
}
The CSVLoader class just uses the getLoaderCommand() in the example above,
but can be enhanced to use other methods mentioned above or more methods
can be added to the interface and each implementing csv can provide it's
own implementation. This simple design above helps load different types
of csv files from a single loader class.
**Regular caveats apply, the code may have some bugs or may just not be
the ideal choice for your implementation. Please feel free to use the above
as a reference for your implementation.
Happy Loading.
public class CSVLoader {
public void execute(LoadableCSV csv) throws Exception{
try {
String comand = init(csv);
service(comand);
} catch (Throwable e) {
throw new Exception(e);
} finally {
shutdown();
}
}
protected String init(LoadableCSV csv) {
StringBuffer command = new StringBuffer();
command.append("sqlldr").append(" ");
command.append(csv.getLoaderCommand());
System.out.println("CSVLoader initialized.");
return command.toString();
}
protected void service(String command) throws Exception {
Runtime r = Runtime.getRuntime();
long startTime = System.currentTimeMillis();
try {
Process process = r.exec(command);
if (process == null) {
System.out.println("Process NOT Initialized for command [" + command + "]");
} else {
// wait for the process to exit
process.waitFor();
System.out.println("Loading completed. Exit Value [" + process.exitValue() + "] Time taken ["
+ (System.currentTimeMillis() - startTime) / 1000 + "] sec");
StringBuffer strBuffer = new StringBuffer();
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = reader.readLine()) != null) {
strBuffer.append(line).append("\n");
}
reader.close();
if (process.exitValue() != 0) {
System.out.println("ERROR:" + strBuffer.toString());
throw new Exception("Sql Loading Exited with [" + process.exitValue() + "]");
} else {
System.out.println("Loader completed execution. \n" + strBuffer.toString());
}
}
} catch (InterruptedException e) {
System.out.println("Exception while waiting for process [" + command + "] to complete");
throw e;
} catch (IOException e) {
System.out.println("Exception executing process [" + command + "]");
}
System.out.println("CSVLoader service done.");
}
protected void shutdown() {
System.out.println("CSVLoader shutdown.");
}
}
The Loader class is invoked from any Java process using a LoadableCSV instance.
LoadableCSV is an interface which can be implemented for different flat files
as per the requirement.
public interface LoadableCSV {
public int getRecordsToSkip();
public int getRecordsToLoad();
public int getErrorsAllowed();
public String getSeparator();
public String getLoaderCommand();
}
The CSVLoader class just uses the getLoaderCommand() in the example above,
but can be enhanced to use other methods mentioned above or more methods
can be added to the interface and each implementing csv can provide it's
own implementation. This simple design above helps load different types
of csv files from a single loader class.
**Regular caveats apply, the code may have some bugs or may just not be
the ideal choice for your implementation. Please feel free to use the above
as a reference for your implementation.
Happy Loading.
发表评论
-
Log4j常用配置
2011-08-29 22:03 1675log4j.rootLogger=INFO, normal ... -
ArrayDeque实现Stack的功能
2011-08-17 15:58 7625在J2SE6引入了ArrayDeque类 ... -
Java的clone()方法,浅复制与深复制
2011-08-15 15:06 1398要想实现克隆,需要实 ... -
LinkedList源码分析
2011-08-10 15:18 1072http://blog.csdn.net/zhouyong0/ ... -
Java nio(文件读写 实例解析)
2011-08-09 18:07 4685http://blog.csdn.net/biexf/arti ... -
深入探讨 Java 类加载器
2011-08-08 15:23 769http://www.ibm.com/developerwor ... -
Java.nio 与Java.io的比较
2011-08-05 18:00 1489http://blogs.oracle.com/slc/ent ... -
java缓冲读写
2011-08-05 15:54 1101public static void main(String[ ... -
java多线程写入同一文件
2011-08-05 15:40 10036转自 :http://www.update8.com/Prog ... -
java线程及ComcurrentHashMap
2011-08-04 13:55 985http://blog.csdn.net/dimly113/a ... -
HashMap源码分析
2011-08-04 13:51 1819public class HashMap<K,V&g ... -
HashMap与HashTable的区别、HashMap与HashSet的关系
2011-08-04 10:44 3427转自http://blog.csdn.net/wl_ldy/a ... -
JVM内存模型及垃圾收集策略解析
2011-07-18 23:16 1321http://blog.csdn.net/dimly113/a ... -
Java关键字final、static使用总结
2011-06-03 12:47 9http://java.chinaitlab.com/base ... -
Java关键字final、static使用总结
2011-06-03 12:47 8一、final 根据程序上下文环境,Java关键字fina ... -
Java关键字final、static使用总结
2011-06-03 12:46 5一、final 根据程序上下文环境,Java关键字fina ... -
Java关键字final、static使用总结
2011-06-02 16:20 0转自:http://java.chinaitlab.com/b ... -
Java关键字final、static使用总结
2011-06-02 16:20 815转自:http://java.chinaitlab.com/b ... -
Java关键字final、static使用总结
2011-06-02 16:19 2转自:http://java.chinaitlab.com/b ... -
protected访问级别详解
2011-05-12 14:42 1675首先阅读:http://download.oracle.com ...
相关推荐
Unknown column 'fillMen' in 'field list' java.sql.SQLException: Operation not ...java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in
In addition, it contains a mechanism which allows java applications to read in a spreadsheet, modify some cells and write out the new spreadsheet. This API allows non Windows operating systems to ...
##### 题目4: ________ consists of a set of separate programs for developing and testing Java programs, each of which is invoked from a command line. - **选项**: - 1. Java Language Specification - 2....
17. 类C的运行结果是"The default constructor of A is invoked",因为每个类的构造器都会调用其父类的构造器。 以上就是Java期末考试模拟习题的部分解析,涵盖了变量命名、关键字使用、循环控制、数组创建、继承和...
CHM格式文档,包含配套源代码。 WebSphere MQ, IBM messaging service, can be incorporated into the ...invoked by .NET or Java applications and also J2EE applications invoked by .NET applications or Java.
11. QueryRunner使用错误:`java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way`提示在调用QueryRunner时没有提供DataSource或Connection,需要确保正确配置。 12. executeQuery...
标签:ant-invoked.jar.zip,ant,invoked,jar.zip包下载,依赖包
修正“the invoked member is not supported in a dynamic assembly.”错误 修改: efproviderwrappertoolkit\entityconnectionwrapperutils.cs (184 ) parseresources 添加: if (asm.gettype().fullname != ...
Console.WriteLine("TimerCallbackMethod invoked"); } ``` #### 3. System.Timers.Timer - **特点**: - 适用于桌面应用程序和服务器端。 - 提供更多配置选项,如精度调整。 - 更高级的API,支持事件处理。 ...
Each entry in the Java stack is called “stack frames“. Whenever a method is invoked a new stack frame is added to the stack and corresponding frame is removed when its execution is completed. ...
该标准主要关注如何将SQL与高级编程语言(如C、Java等)进行集成,以便程序员能够在这些语言中使用SQL来访问数据库。 #### 规范参考 在该标准的第二章中,列出了所有必需遵循的规范性引用文件,这些文件对于理解...
- **选项:** a) Superclass object b) The object invoked the method c) Any object used in the application d) Ignore - **答案与解析:** 正确答案是b) The object invoked the method。“this”关键字主要用于...
he discipline of game theory was pioneered ...on the context in which the game theoretic language is invoked: in evolutionary biology (see, for example, John Maynard Smith, 1982) players are Chapter 0 T
In addition, the Java language is gaining increasing popularity in developing distributed systems. Most previous works on updating are concerned with safely updating one class every time. It has many...
expression to the @MethodPattern annotation in LintDetectorStats.java, you might see a line like this. Conversely, it's a good sign if you see a line like this. If you make code changes to the tool, ...
When Goto is invoked on an external type in XAML, VA prompts to open the Object Browser (instead of searching it without prompting). (case=96541) Find Symbol in Solution dialog lists symbols defined ...
let okAction = UIAlertAction(title: "确定", style: .default) { _ in // 用户点击“确定”时执行的代码 } alertController.addAction(okAction) present(alertController, animated: true, completion: nil) ```...
A Standard Test can be invoked from the popup menu when right-clicking on the function or procedure in the Object Browser or in a PL/SQL source: The Test Window now supports Oracle12c implicit ...
Causes the next filter in the chain to be invoked, or if the calling filter is the last filter in the chain, causes the resource at the end of the chain to be invoked. doFilter(ServletRequest, ...
jclasslib bytecode viewer Purpose jclasslib bytecode viewer is a tool that visualizes all aspects ...can be invoked when a Java, Groovy or Kotlin file is open in the editor. The bytecode will be shown i