这行代码开始警告没有配置mysql方言,
但我配置了全局方言后又报错说无法解析表,
除此之外所有的表和列都有报错,
明明数据库里面有这些表,
请问如何解决?
package lib.Dao;
import java.sql.*;
/**
* Created by ttop5 on 16-4-18.
*/
public class StudentDAO {
// public String getNotes() throws SQLException {
// Statement stmt = null;
// Dbutil dbutil = new Dbutil();
// Connection con = null;
// ResultSet rs = null;
// String str = "<table class=\"table table-bordered\" id=\"outside\">" +
// "<tr><th>标题</th><th>时间</th><th>公告内容</th></tr>";
// try{
// con = dbutil.getCon();
// stmt = con.createStatement();
// String sql = "select title, start_time, description from notes" + ";";
// rs = stmt.executeQuery(sql);
// while(rs.next()) {
// str = str + "<tr>" + "<td>" + rs.getString("title") + "</td>" + "<td>" + rs.getDate("start_time") + "</td>" + "<td>" + rs.getString("description") + "</td>" + "</tr>";
// }
// return str + "</table>";
// }catch (Exception e) {
// e.printStackTrace();
// }
// return str;
// }
public String getNotes() throws SQLException{
Statement stmt = null;
Dbutil dbutil = new Dbutil();
Connection con = null;
ResultSet rs = null;
String str = "<table class=\"table table-bordered\" id=\"outside\">" +
"<tr><th>标题</th><th>开始时间</th><th>结束时间</th><th>公告内容</th></tr>";
try{
con = dbutil.getCon();
stmt = con.createStatement();
String sql = "select * from notes" + ";";
rs = stmt.executeQuery(sql);
while(rs.next()) {
str = str + "<tr>" + "<td>" + rs.getString("title") + "</td>" + "<td>" + rs.getString("start_time") + "</td>" + "<td>" + rs.getString("stop_time") + "</td>" + "<td>" + rs.getString("description") + "</td>" + "</tr>";
}
return str + "</table>";
}catch (Exception e) {
e.printStackTrace();
}
return str;
}
public String getScore(String email) throws SQLException{
Statement stmt = null;
Dbutil dbutil = new Dbutil();
Connection con = null;
ResultSet rs = null;
String str = "<table class=\"table table-bordered\" id=\"outside\">" +
"<tr><th>课程号</th><th>课程名</th><th>学分</th><th>平时成绩</th><th>期末成绩</th><th>最终成绩</th></tr>";
try{
con = dbutil.getCon();
stmt = con.createStatement();
String sql = "select cource_id, cource_name, credit, pingshi_score, qimo_score, final_score from score, user, cource where student=user_id and cource=cource_id AND email='" + email + "';";
rs = stmt.executeQuery(sql);
while(rs.next()) {
str = str + "<tr>" + "<td>" + rs.getInt("cource_id") + "</td>" + "<td>" + rs.getString("cource_name") + "</td>" + "<td>" + rs.getString("credit") + "</td>" + "<td>" + rs.getString("pingshi_score") + "</td>" + "<td>" + rs.getString("qimo_score") + "</td>" + "<td>" + rs.getString("final_score") + "</td>" + "</tr>";
}
return str + "</table>";
}catch (Exception e) {
e.printStackTrace();
}
return str;
}
public String getScource(String email) throws SQLException{
Statement stmt = null;
Dbutil dbutil = new Dbutil();
Connection con = null;
ResultSet rs = null;
String str = "<table class=\"table table-bordered\" id=\"outside\">" +
"<tr><th>课程号</th><th>课程名称</th><th>学分</th><th>上课时间</th><th>上课地点</th></tr>";
try{
con = dbutil.getCon();
stmt = con.createStatement();
String sql = "select cource_id, cource_name, credit, schooltime, location from score, user, cource, classroom where student=user_id and cource=cource_id and classroom=classroom_id AND email='" + email + "';";
rs = stmt.executeQuery(sql);
while(rs.next()) {
str = str + "<tr>" + "<td>" + rs.getInt("cource_id") + "</td>" + "<td>" + rs.getString("cource_name") + "</td>" + "<td>" + rs.getString("credit") + "</td>" + "<td>" + rs.getString("schooltime") + "</td>" + "<td>" + rs.getString("location") + "</td>" + "</tr>";
}
return str + "</table>";
}catch (Exception e) {
e.printStackTrace();
}
return str;
}
public String getUser(String email) throws SQLException{
Statement stmt = null;
Dbutil dbutil = new Dbutil();
Connection con = null;
ResultSet rs = null;
String str = "<table class=\"table table-bordered\" id=\"outside\">" +
"<tr><th>学号</th><th>姓名</th><th>性别</th><th>年级</th><th>学院</th><th>专业</th><th>班级</th><th>QQ</th><th>电话</th><th>邮箱</th><th>地址</th><th>角色</th></tr>";
try{
con = dbutil.getCon();
stmt = con.createStatement();
String sql = "select * from user WHERE email='" + email + "';";
rs = stmt.executeQuery(sql);
while(rs.next()) {
str = str + "<tr>" + "<td>" + rs.getString("school_num") + "</td>" + "<td>" + rs.getString("name") + "</td>" + "<td>" + rs.getString("sex") + "</td>" +"<td>" + rs.getString("grade") + "</td>" + "<td>" + rs.getString("school") + "</td>" + "<td>" + rs.getString("major") + "</td>" + "<td>" + rs.getString("class") + "</td>" + "<td>" + rs.getString("qq") + "</td>" + "<td>" + rs.getString("phone") + "</td>" + "<td>" + rs.getString("email") + "</td>" + "<td>" + rs.getString("adress") + "</td>" + "<td>" + rs.getString("role") + "</td>" +
"<td><button type=\"button\" class=\"btn btn-success\">编辑</button></td>" + "</tr>";
}
return str + "</table>";
}catch (Exception e) {
e.printStackTrace();
}
return str;
}
}