0

I have a mysql database that I want to connect to my Java (Spring MVC) project (I'm using IntelliJ). As I learned, I defined the entities and repositories in IntelliJ equivalent to the database's tables. However, I wrote a short code that is able to connect to my datatbase, run sql queries and save/print the query's results:

public static void main(String args[]){ try{ Class.forName("com.mysql.jdbc.Driver"); // Connecting to mySql Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/theprocess?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC","root","root"); // Connecting to our database Statement stmt = con.createStatement(); // Object that allows executing SQL queries ResultSet rs = stmt.executeQuery("select * from clients"); // Storing the query's result while(rs.next()) System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3)); // Defines which columns to print con.close(); // Closing the connection; }catch(Exception e){ System.out.println(e);} } 

So my question is, do I even need the entities and repositories if I have that code? Thanks for your help :)

2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.