Good evening.

I need to write in Java a database in graphical mode, in which I need to implement adding, changing, deleting and sorting data.

Advise any books, video tutorials, forums to solve this problem.

  • database? wtf? Subd can still? - johniek_comp
  • I think there’s a lot of common sense here and you just need to write pseudo-bd, for example an array with CRUD operations .... - Gorets
  • Yes, yes. Most likely this is it (i.e., “pseudo DB, for example, an array with CRUD operations ....”) By virtue of my computer illiteracy, I could not more accurately formulate the question. - Omfis
  • 2
    > "write a database in graphic mode in Java" This phrase is a silent horror. How can you be so lazy? You did not even bother to look at the wiki to properly raise the question ... - jmu


1 answer 1

Good day. I did not find exact information on this question. I had to choose different information from different sources and think for myself. I can help with a piece of code.

import java.sql.*; public class Mysql { private static Connection conn = null; /** * * Метод осуществляет подключение к базе данных с заданными параметрами * * @param mysql_login текстовая переменная, является именем пользователя * базы данных * @param mysql_pass текстовая переменная, является паролем имени * пользователя базы данных * @param mysql_db текстовая переменная, является именем базы данных, к * которой идет подключение * @throws SQLException * */ public static void connect(String mysql_login, String mysql_pass, String mysql_db) throws SQLException { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc: mysql://localhost/" + mysql_db, mysql_login, mysql_pass); System.out.println("The connection was successful."); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e) { System.err.println("Cannot connect to database server"); } } /** * * Метод для запроса в БД * * @param query Строка запроса в БД * @throws SQLException */ public static void com(String query) throws SQLException { try (Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(query)) { while (rs.next()) { System.out.println(rs.getString(1)); } } } /** * Закрытие подключения к БД * * @throws SQLException */ public static void close() throws SQLException { conn.close(); } 

Next, using the query method in the database add, delete, sort the data; But this is Mysql queries. For this topic: LINK For java, you can also watch a course of LECTURES From the books: "Bruce Ekkel. The Philosophy of Java" and "Joshua Bloch. Java. Effective programming"

  • one
    Thanks) - Omfis