Hallo,
wenn ich diesen Code ausführe, dann werden ein Haufen Fehlermeldungen geworfen.
Weiß einer woran das liegt?
wenn ich diesen Code ausführe, dann werden ein Haufen Fehlermeldungen geworfen.
Weiß einer woran das liegt?
Java:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class InsertDataDB {
public static void main(String[] args){
String url="jdbc:mysql://localhost:3306/demo";
String user="Admin";
String password="12345";
try{
// 1. Get a connection to database
Connection myConn = DriverManager.getConnection(url,user,password);
// 2. Create a Statement
Statement myStmt = myConn.createStatement();
// 3. Execute SQL Query
String sql = "INSERT INTO employees"
+ " (last_name, first_name, email)"
+ " VALUES ('Brown', 'David', 'david.brown@foo.com')";
myStmt.executeUpdate(sql);
System.out.println("Insert complete");
}
catch(Exception exc){
exc.printStackTrace();
}
}
}
HTML:
Sun Nov 26 22:53:29 CET 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
java.sql.SQLException: Field 'id' doesn't have a default value
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2483)
at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1552)
at com.mysql.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2607)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1480)
at InsertDataDB.main(InsertDataDB.java:32)