diff --git a/README.md b/README.md index f77766a..bbd7983 100644 --- a/README.md +++ b/README.md @@ -1 +1,8 @@ -#muudle-anyreport \ No newline at end of file +#muudle-anyreport +Назначение: +программа muudle-anyreport предназначена для формирования отчетов по результатам обучения пользователей платформы moodle. + +Для доступа к данным используется подключение к базе данных сервера, необходимо указать: +- логин +- пароль +- url сервера базы данных, обслуживающего moodle diff --git a/doc/anyreport.puml b/doc/anyreport.puml index 304a90b..9eccf38 100644 --- a/doc/anyreport.puml +++ b/doc/anyreport.puml @@ -71,12 +71,15 @@ package moodle-anyreport{ class Base{ - connection : Connection - login : String - - password : Array - - url : String + - password : String + - link : String + setConnection(Connection connaction) : void + getConnaction() : Connaction - + connect() : bolean - + disconnect() : void + + connect(Base b) : void + + disconnect(Base b) : void + ' запрос к базе, возвращает ответ + + querry(String querry) : ResultSet + } Base --> Data Base --> AccessControls diff --git a/src/App.java b/src/App.java index 46a8aea..7d1e6b3 100644 --- a/src/App.java +++ b/src/App.java @@ -1,7 +1,24 @@ -public class App { +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.WindowConstants; + +/** + * Основной класс сборки приложения + */ +public class App extends JPanel{ + public void init(){ + JFrame mainframe = new JFrame("mainframe"); + mainframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + mainframe.add(this); + mainframe.setSize(640, 480); + mainframe.setVisible(true); + mainframe.setExtendedState(mainframe.MAXIMIZED_BOTH); + } public static void main( String[] args ) { System.out.println( "Работает подготовщик отчетов по результатам тестирования пользователей ..." ); + App anyreport = new App(); + anyreport.init(); } } diff --git a/src/Base.java b/src/Base.java new file mode 100644 index 0000000..8b3ff50 --- /dev/null +++ b/src/Base.java @@ -0,0 +1,94 @@ +import java.sql.Connection; +import java.sql.DriverManager; + +public class Base { + private Connection connection; + private String link; + private String login; + private String password; + //request + //response + Base(String link, String login, String password){ + setLink(link); + setLogin(login); + setPassword(password); + } + /** + * @param connection the connection to set + */ + public void setConnection(Connection connection) { + this.connection = connection; + } + /** + * @return the connection + */ + public Connection getConnection() { + return connection; + } + /** + * @param link the link to set + */ + public void setLink(String link) { + this.link = link; + } + /** + * @return the link + */ + public String getLink() { + return link; + } + /** + * @param login the login to set + */ + public void setLogin(String login) { + this.login = login; + } + /** + * @return the login + */ + public String getLogin() { + return login; + } + /** + * @param password the password to set + */ + public void setPassword(String password) { + this.password = password; + } + /** + * @return the password + */ + public String getPassword() { + return password; + } + //подключение к базе + public void connect(){ + System.out.println("Подключение к серверу баз данных ..."); + Connection conn = null; + try{ + conn = DriverManager.getConnection (getLink(), getLogin(), getPassword()); + System.out.println ("Подключение к серверу баз данных установлено ... "); + } + catch (Exception ex){ + System.err.println ("Подключение к серверу баз данных не установлено ... "); + ex.printStackTrace(); + System.out.println (ex); + } + setConnection(conn); + } + //отключение от базы + public void disconnect(){ + if (getConnection() != null){ + try{ + System.out.println("Попытка отключения от базы данных ... "); + getConnection().close (); + System.out.println ("Подключение к базе данных завершено. "); + } + catch (Exception ex){ + System.out.println ("Подключение к серверу баз данных уже отсутствует."); + System.out.println (ex); + } + } + } + +}