I've got two classes:
MAIN and DBCONNECT
DBCONNECT has all the coding including the methods that will connect to, insert and update a database/table.
MAIN is where my GUI is created and uses the DBCONNECT class.
In my DBCONNECT class I have created a method that writes the input info to a table.
String sqlInsert1 = "INSERT INTO Drivers (IDNumber, FirstName, LastName) VALUES " + Id +"," + FirstName+"," + Surname;
String sqlInsert2 = "INSERT INTO Offences(IDNumber, SpeedLimit, DriverSpeed, SeatBelt, DrunkenDriving, DriversLicense) VALUES" + Id + SpeedLimit + DriversSpeed + Seatbelt + DrunkenDriving + License;
String sqlInsert3 = "INSERT INTO DriverPoints(IDNumber, Points) VALUES" + Id + Points;
public void writeToDB(String sqlInsert1, String sqlInsert2, String sqlInsert3)
{
try
{
Statement st = conn.createStatement();
st.executeUpdate(sqlInsert1);
st.executeUpdate(sqlInsert2);
st.executeUpdate(sqlInsert3);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "Error: Could not read from database");
}
}
And In my MAIN class I want to use this method when the Save button is clicked
public void actionPerformed(ActionEvent ae)
{
if (ae.equals(save))
{
database.writeToDB();
}
}
It keeps giving me an error
required:java.language.String,java.language.String,java.language.String
Please let me know what I am doing wrong here.