Hallo,
ich wollte einen Eintrag in meine Datenbank machen, nur bringt er mir immer den Fehler:
"java.sql.SQLException: Column count doesn't match value count at row 1"
Habt ihr eine idee, was ich falsch mache?
Gruß Robin
ich wollte einen Eintrag in meine Datenbank machen, nur bringt er mir immer den Fehler:
"java.sql.SQLException: Column count doesn't match value count at row 1"
Code:
public void DBeintrag(String cmdV,String cmd0, String cmd1, String cmd2) {
try {
// Load the JDBC driver
String driverName = "com.mysql.jdbc.Driver";
Class.forName(driverName);
// Create a connection to the database
Connection connection = null;
String serverName = "localhost";
String mydatabase = "rtt_db";
String url = "jdbc:mysql://localhost/" + mydatabase; // a JDBC url
String username = "root";
String password = "";
connection = DriverManager.getConnection(url, username, password);
// insert into DB
Statement statement = connection.createStatement();
String sql_in = "INSERT INTO renderauftrag VALUES(cmd0,cmd1,cmd2,cmdV)";
int ok = statement.executeUpdate(sql_in);
System.out.println(ok);
}
catch (ClassNotFoundException e) {System.out.println("Could not find the database driver");}
catch (SQLException e) {System.out.println("Could not connect to the database" +"\n" +e);}
}
Habt ihr eine idee, was ich falsch mache?
Gruß Robin