我写的程序执行到这里时出错了,控制台显示Can't find file: '.\hello\@0024table.frm' (errno: 2 - No such file or directory),上网查说是权限问题,请问怎么解决?newName:hll
oldName:helloconn=DBUtil.getConnection(newName);
for (int i = 0; i < tableList.size(); i++) {
sql = "rename table "+oldName+".$table to "+newName+".$table";
ptmt = conn.prepareStatement(sql);
; ptmt.execute();
}
if(ptmt!=null){ptmt.close();}
if(conn!=null){conn.close();}
oldName:helloconn=DBUtil.getConnection(newName);
for (int i = 0; i < tableList.size(); i++) {
sql = "rename table "+oldName+".$table to "+newName+".$table";
ptmt = conn.prepareStatement(sql);
; ptmt.execute();
}
if(ptmt!=null){ptmt.close();}
if(conn!=null){conn.close();}
解决方案 »
- new 出大量的静态内部类会不会造成方法区溢出?
- 请教一个swing布局问题(带图)
- itext 解析 pdf
- 读取文件时在jbuilder中出错,但在jcreator中没有问题
- 怎样在simpledateformat中的format与oracle中date型的format之间进行转换?
- 大家帮忙解释一下这个程序是如何执行得到这个结果的,谢谢!
- 在用到JFrame时遇到的一个问题
- 请教各位大哥一个关于jdk1.3安装的问题!!
- Java Applet 中是否有定时器的机制
- jdbc连接mysql,myeclipse出现错误,eclipse下可以正常连接,jar都正常引入
- 8个包装类和String和其他类生成对象的不同之处
- 求大佬解惑
public static void renameDataBase(String newName, String oldName) {
PreparedStatement ptmt;
try {
//一开始必须填一个已经存在的数据库
Connection conn = DBUtil.getConnection("lannong");
//创建数据库
String sql = "create database if not exists "+newName;
ptmt = conn.prepareStatement(sql);
ptmt.executeUpdate();
ptmt.close();
conn.close();
ArrayList<String> tableList = new ArrayList<>();
//打开原来的数据库
conn=DBUtil.getConnection(oldName);
sql = "select table_name from information_schema.TABLES where TABLE_SCHEMA=?";
ptmt=conn.prepareStatement(sql);
ptmt.setString(1, oldName);
ResultSet rs = ptmt.executeQuery();
while(rs.next()){
tableList.add(rs.getString("table_name"));
}
if (rs!=null) {rs.close();}
if(ptmt!=null){ptmt.close();}
if(conn!=null){conn.close();}
for (int i = 0; i < tableList.size(); i++) {
System.out.println(tableList.get(i));
}
conn=DBUtil.getConnection(newName);
for (int i = 0; i < tableList.size(); i++) {
sql = "rename table "+oldName+".$table to "+newName+".$table";
ptmt = conn.prepareStatement(sql);
; ptmt.execute();
}
if(ptmt!=null){ptmt.close();}
if(conn!=null){conn.close();}
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}这个程序我是用于重命名数据库的,请问这时难道不是连接新的数据库吗
根据这篇文章的第三种方法写的http://www.blogjava.net/xiaomage234/archive/2014/07/31/416389.html