Ich versuche, eine neue Tabelle in einer Datenbank zu erstellen, aber ich bin erhalte eine Fehlermeldung, die besagt:Fehler bei der Erstellung von Tabellen
Exception in thread „main“ java.sql.SQLSyntaxErrorException: Tabelle/View ‚USERPRIVACYDB ' ist nicht vorhanden.
Der Code ist wie folgt:
public class UserPrivacyData {
private static String password = null;
private final static String USER = "root";
final String DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
final String DATABASE_URL = "jdbc:derby://localhost:1527/USERPRIVACYDB;create=true;";
public void loadDB() throws SQLException {
try {
Class.forName(DRIVER); //load the driver
connection = DriverManager.getConnection(DATABASE_URL, USER, password);
statement = connection.createStatement();
} catch (Exception ex) {
ex.printStackTrace();
}
String sql = "insert into USERPRIVACYDB values('" + gender[rand.nextInt(2)] + "',"
+ " '" + privacyLevel[rand.nextInt(3)] + "', '" + age[rand.nextInt(3)] + "',"
+ " '" + presentEducationLevel[rand.nextInt(3)] + "',"
+ " '" + highestEducation[rand.nextInt(3)] + "', '"
+ everVictimOfCrimeString + "', "
+ " '" + crimeTypeString + "', "
+ " '" + shareWithThirdParty[rand.nextInt(2)] + "',"
+ " '" + reasonforChoiceofPrivacy[rand.nextInt(5)] + "')";
statement.executeUpdate(sql);
// }
}
}
Kann jemand mir bitte helfen? Vielen Dank.
Wo ist demonstriert Code, wie Sie diese Fehlermeldung erhalten? Bitte lesen Sie die [Hilfe] – Liam
Danke Liam. Der Code lautet wie folgt: – user3048253
public class UserPrivacyData { private static Zeichenfolge Kennwort = null; private final static Zeichenfolge USER = "root"; letzte Zeichenfolge DRIVER = "org.apache.derby.jdbc.EmbeddedDriver"; final Zeichenfolge DATABASE_URL = "jdbc: derby: // localhost: 1527/USERPRIVACYDB; create = true;"; public void loadDB() löst SQLException aus { try { Class.forName (DRIVER); // lade den Treiber connection = DriverManager.getConnection (DATABASE_URL, USER, Passwort); \t Anweisung = connection.createStatement(); } catch (Ausnahme ex) {ex.printStackTrace(); } – user3048253