<%
String database = (String)request.getParameter("database");
String table = (String)request.getParameter("table");
%>
......
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost/jspdev?user=root&password=root&allowMultiQueries=true");
Statement stmt = con.createStatement();
String sql = new String("use " + database + "; select * from " + table);
ResultSet rst = stmt.executeQuery(sql1);
......
use database;
这条执行了;
select * from table;
这条执行不了;
帮忙看看!谢!
------解决方案--------------------------------------------------------
批处理,
使用addBatch,
不闲花时间,这里有简单的例子看:
http://zhoujingxian.javaeye.com/blog/753523
------解决方案--------------------------------------------------------
select * from databaseName.tablename
------解决方案--------------------------------------------------------
这两句SQL本身就能用一句来完成,为什么还非要用两句呢。
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost/jspdev?user=root&password=root&allowMultiQueries=true");
Statement stmt = con.createStatement();
String sql = new String("select * from " + database +"."+ table);
ResultSet rst = stmt.executeQuery(sql1);
------解决方案--------------------------------------------------------
如果多条语句需要同时执行,实现同一性。
用事务吧,存储过程也可以。