public static void main(String[] args) {
String jhlsh = null;
String jhlsh2 = null;
int id = 0;
int num;
try {
Connection con = Util.getConnection();
Statement stmt = con.createStatement();
ResultSet res = stmt
.executeQuery("select jhlsh from test_id where yljg= '00000001'");
while (res.next()) {
jhlsh = res.getString("jhlsh");
}
id = Integer.parseInt(jhlsh) + 1;
jhlsh2 = id + "";
switch (jhlsh2.length()) {
case 1:
jhlsh2 = "000" + jhlsh2;
break;
case 2:
jhlsh2 = "00" + jhlsh2;
break;
case 3:
jhlsh2 = "0" + jhlsh2;
break;
case 4:
jhlsh2 = jhlsh2;
break;
}
int i = stmt.executeUpdate("update test_id set jhlsh ='" + jhlsh2
+ "' where yljg = '00000001'");
res.close();
stmt.close();
con.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Calendar calendar = Calendar.getInstance();
SimpleDateFormat smp = new SimpleDateFormat("yyyyMMdd");
Date d = calendar.getTime();
try {
Runtime.getRuntime().exec(
"exp zjhit/zjhit@DRG file=d://daochu00000001" + jhlsh2
+ smp.format(d) + ".dmp tables=(ACE_MEDLIST)");
} catch (IOException e1) {
e1.printStackTrace();
}
File f = new File("d:/daochu00000001" + jhlsh2 + smp.format(d) + ".dmp");
while (!f.exists()) {
System.out.println("无文件");
}
String rarPath = "C:\\Program Files\\WinRAR\\WinRAR.exe";
String cmd = "";
String zipfile;
String foler;
zipfile = "d:/daochu00000001" + jhlsh2 + smp.format(d) + ".zip";
foler = "d:/daochu00000001" + jhlsh2 + smp.format(d) + ".dmp";
cmd = rarPath + " m -hp123456 " + zipfile + " " + foler;
System.out.println(cmd);
try {
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }我现在运行这段代码的时,出现一个错误。
! d:\daochu00000001007120091111.zip: 无法打开 daochu00000001007120091111.dmp
! 另一个程序正在使用此文件,进程无法访问。
是怎么回事啊?
高手帮忙解决一下……
解决方案 »
- windows 下 配置 tomcat 服务器问题 急急急!!!!
- XSLT 中怎么转义输出大括号,像 {name}
- Hibernate 多对多 删除中间表。
- struts2 文件上传 获取含中文的文件名称
- ssh整合配置的时候出现问题The requested resource (Servlet action is not available) is not available.
- 图片上传问题(急)
- 用jms是否可以发送文件?????????
- 这两种调用连接池的方法有什么不同?
- 如何关闭jb7中的历史记录功能
- 连接不到远程数据库服务器
- spring动态选择数据库,怎么做比较好?
- myeclipse 6.5 Oracle 10g tomcate 5.5 环境下 在debug模式下可正常通过,但在正常环境下运行出错
点那个,看看你这个PG是不是启动过几次了。
估计你是启动多次了,上一次还没关,这次有启动了。
"exp zjhit/zjhit@DRG file=d://daochu00000001" + jhlsh2
+ smp.format(d) + ".dmp tables=(ACE_MEDLIST)");
; 2.File f = new File("d:/daochu00000001" + jhlsh2 + smp.format(d) + ".dmp");
3.Runtime.getRuntime().exec(cmd);
都在使用dmp文件,1文件使用完后没有关闭,所以造成2,3使用的时候冲突