|
|
@ -1,6 +1,7 @@
|
|
|
|
package dao;
|
|
|
|
package dao;
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.*;
|
|
|
|
import java.sql.*;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
@ -29,6 +30,32 @@ public class DBManagement {
|
|
|
|
"graduation_design_reply",
|
|
|
|
"graduation_design_reply",
|
|
|
|
"graduation_design_reply_opinion_record_score"
|
|
|
|
"graduation_design_reply_opinion_record_score"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
public static String[] studentInfo = {
|
|
|
|
|
|
|
|
"id",
|
|
|
|
|
|
|
|
"password",
|
|
|
|
|
|
|
|
"name",
|
|
|
|
|
|
|
|
"e_mail_location",
|
|
|
|
|
|
|
|
"phone_number",
|
|
|
|
|
|
|
|
"grade",
|
|
|
|
|
|
|
|
"profession_code"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
public static String[] teacherInfo = {
|
|
|
|
|
|
|
|
"id",
|
|
|
|
|
|
|
|
"password",
|
|
|
|
|
|
|
|
"name",
|
|
|
|
|
|
|
|
"e_mail_location",
|
|
|
|
|
|
|
|
"phone_number",
|
|
|
|
|
|
|
|
"job_title",
|
|
|
|
|
|
|
|
"education",
|
|
|
|
|
|
|
|
"profession_code"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
public static String[] administratorInfo = {
|
|
|
|
|
|
|
|
"id",
|
|
|
|
|
|
|
|
"password",
|
|
|
|
|
|
|
|
"name",
|
|
|
|
|
|
|
|
"e_mail_location",
|
|
|
|
|
|
|
|
"phone_number"
|
|
|
|
|
|
|
|
};
|
|
|
|
//<table1.x_id,table2.x_status>
|
|
|
|
//<table1.x_id,table2.x_status>
|
|
|
|
public static Map<String,String> graduationDesignStudentTables = new HashMap<>(){
|
|
|
|
public static Map<String,String> graduationDesignStudentTables = new HashMap<>(){
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -79,7 +106,7 @@ public class DBManagement {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static Map<String,String> getUserTables(String userType){
|
|
|
|
public static Map<String,String> getUserStatusTables(String userType){
|
|
|
|
if(userType.equals("student")){
|
|
|
|
if(userType.equals("student")){
|
|
|
|
return graduationDesignStudentTables;
|
|
|
|
return graduationDesignStudentTables;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -88,7 +115,18 @@ public class DBManagement {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String[] getUserInfoTables(String userType){
|
|
|
|
|
|
|
|
if(userType.equals("administrator")){
|
|
|
|
|
|
|
|
return administratorInfo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(userType.equals("student")){
|
|
|
|
|
|
|
|
return studentInfo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(userType.equals("teacher")){
|
|
|
|
|
|
|
|
return teacherInfo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
public static void delete(String table, Map<String,String> limits) throws GExcptSQL {
|
|
|
|
public static void delete(String table, Map<String,String> limits) throws GExcptSQL {
|
|
|
|
Delete delete = new Delete(table, limits);
|
|
|
|
Delete delete = new Delete(table, limits);
|
|
|
|
String sql = delete.getSQL();
|
|
|
|
String sql = delete.getSQL();
|
|
|
@ -99,7 +137,7 @@ public class DBManagement {
|
|
|
|
String sql = insert.getSQL();
|
|
|
|
String sql = insert.getSQL();
|
|
|
|
update(sql);
|
|
|
|
update(sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static ResultSet select(List<String> columns, String table, Map<String,String> limits, int startRow, int endRow) throws Exception {
|
|
|
|
public static List<String[]> select(List<String> columns, String table, Map<String,String> limits, int startRow, int endRow) throws Exception {
|
|
|
|
Select select = new Select(columns,table,limits,startRow,endRow);
|
|
|
|
Select select = new Select(columns,table,limits,startRow,endRow);
|
|
|
|
String sql = select.getSQL();
|
|
|
|
String sql = select.getSQL();
|
|
|
|
return query(sql);
|
|
|
|
return query(sql);
|
|
|
@ -109,15 +147,24 @@ public class DBManagement {
|
|
|
|
String sql = update.getSQL();
|
|
|
|
String sql = update.getSQL();
|
|
|
|
update(sql);
|
|
|
|
update(sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static ResultSet query(String sql) throws Exception {
|
|
|
|
public static List<String[]> query(String sql) throws Exception {
|
|
|
|
if(!ifInit) return null;
|
|
|
|
if(!ifInit) return null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
List<String[]> ls;
|
|
|
|
Connection con = null;
|
|
|
|
Connection con = null;
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
con = DBManagement.getConnection();
|
|
|
|
con = DBManagement.getConnection();
|
|
|
|
Statement stmt = con.createStatement();
|
|
|
|
Statement stmt = con.createStatement();
|
|
|
|
rs = stmt.executeQuery(sql);
|
|
|
|
ResultSet rs = stmt.executeQuery(sql);
|
|
|
|
System.out.println(rs);
|
|
|
|
ResultSetMetaData rsm = rs.getMetaData() ;
|
|
|
|
|
|
|
|
int columnCount = rsm.getColumnCount();
|
|
|
|
|
|
|
|
ls = new ArrayList<>();
|
|
|
|
|
|
|
|
while(rs.next()){
|
|
|
|
|
|
|
|
String[] s = new String[columnCount];
|
|
|
|
|
|
|
|
for(int i=0;i<columnCount;i++){
|
|
|
|
|
|
|
|
s[i] = rs.getString(i+1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ls.add(s);
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new GExcptSQL("Connect Failure");
|
|
|
|
throw new GExcptSQL("Connect Failure");
|
|
|
|
}finally {
|
|
|
|
}finally {
|
|
|
@ -129,7 +176,7 @@ public class DBManagement {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rs;
|
|
|
|
return ls;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static void update(String sql) throws GExcptSQL {
|
|
|
|
public static void update(String sql) throws GExcptSQL {
|
|
|
|
if(!ifInit) return;
|
|
|
|
if(!ifInit) return;
|
|
|
|