I have a programe to read data to a data base. however it only takes preconfigured input rather than user input via my gui. Ive tryed using getters and setters but can,t seem to get the correct result . how can i change the following code to take gui input.My gui is in a different class.
public void add_data( ){
try {
makeStatement = dbConnection.createStatement();
String insertSQL = "INSERT INTO Library (ID,Song,Artist,Album) " +
"VALUES (2,'any song', 'any artist', 'any album');";
System.out.println("data created");
makeStatement.executeUpdate(insertSQL);
makeStatement.close();
dbConnection.commit();
dbConnection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Aucun commentaire:
Enregistrer un commentaire