2 years ago
#63240

Љубинко Стојановић - Смртник
The database does not display the data in the table added via the JAVA program
I have a problem with the database, I have no idea what's going on. When I want to add data to the database, nothing happens, but when I add them via MySQL Workbench, usersid numbers (primary key) are occupied, but it does not show them in the table.
void createConnection() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
this.con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb",
"root", "admin");
System.out.println("Database is connected.");
} catch (ClassNotFoundException ex) {
Logger.getLogger(BazaPodatakaVerzija1.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(BazaPodatakaVerzija1.class.getName()).log(Level.SEVERE, null, ex);
}
}
try {
java.sql.Statement stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO USERS(name, password, email) VALUES ('3dsdadsadfa', '34fd65652', 'fhjgjfgdh76')");
// stmt.executeUpdate("INSERT INTO USERS(name, password, email) VALUES ('" + ime_TF.getText() + "', '" + lozinka_TF.getText() + "', '" + email_TF.getText() +"')");
} catch (SQLException ex) {
Logger.getLogger(InterfejsGIO.class.getName()).log(Level.SEVERE, null, ex);
}
java
mysql
mysql-workbench
mysql-connector
0 Answers
Your Answer