proc.setString(1, s[i][0]);
proc.setString(2, s[i][1]);
proc.setString(3, s[i][2]);
proc.setString(4, s[i][3]);
proc.setDate(5, new Date(dOB.parse(s[i][4]).getTime()));
proc.setString(6, s[i][5]);
proc.setInt(7, (int) Double.parseDouble(s[0][6]));
proc.setInt(8, Integer.parseInt(s[i][7]));
proc.setString(9, s[i][8]);
proc.setInt(10, (int) Double.parseDouble(s[i][9]));
ResultSet rs = proc.executeQuery();
while (rs.next()) {
if (rs.getString(1) != null)
edited++;
else if (rs.getString(2) != null)
wrong++;
else aded++;
}
}
int[] stat = new int[3];
stat[0] = aded;
stat[1] = edited;
stat[2] = wrong;
return stat;
}
public ResultSet executeQuery(String s) {
try {
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery(s);
return rs;
} catch (SQLException ex) {
Logger.getLogger(DBManager.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
public void closeConnection() {
try {
connection.close();
} catch (SQLException ex) {
Logger.getLogger(DBManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Класс для работы с подсистемой «Деканат»:
public class DBFReader {
public static Connection getConnection() {
Connection conn = null;
try {
Class.forName("com.hxtt.sql.dbf.DBFDriver");
Properties conProperties = new Properties();
conProperties.put("charSet", "Cp866");
conn = DriverManager.getConnection("jdbc:dbf:/D:/JavaDB/", conProperties);
return conn;
} catch (ClassNotFoundException ex) {
Logger.getLogger(DBFReader.class.getName()).log(Level.SEVERE, null, ex);
return conn;
} catch (SQLException ex) {
Logger.getLogger(DBFReader.class.getName()).log(Level.SEVERE, null, ex);
return conn;
}
}
public static ResultSet executeQuery(Connection conn, String query) {
try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
return rs;
} catch (SQLException ex) {
Logger.getLogger(DBFReader.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
public static String[][] getTable(ResultSet rs) {
try {
ResultSetMetaData rsmd = rs.getMetaData();
int colums = rsmd.getColumnCount();
ArrayList<String[]> base = new ArrayList<String[]>();
String[] names = new String[colums];
while (rs.next()) {
ArrayList<String> row = new ArrayList<String>();
for (int i = 0; i < colums; i++) {
row.add(rs.getString(i + 1));
}
base.add(row.toArray(new String[colums]));
}
String[][] arr = base.toArray(new String[base.size()][base.get(0).length]);
return arr;
} catch (SQLException ex) {
Logger.getLogger(DBManager.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
}
Основной класс приложения:
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.