I've created a DB in Microsoft Access, and now i'm trying to add to some tables data with java.
while the select queries work just fine, i can't make the insert query work.
it does'nt give me any errors, but it's not adding any thing to the DB.
any help will be very much appreciated.
private static Connection getConnection() throws Exception {
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:BabySitterAgency";
String username = "";
String password = "zsczd";
try{
Class.forName(driver);}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage()); }
return DriverManager.getConnection(url, username, password);
}
public static void EndOfHire(int S_id, int P_id, float Rank, String Comment)throws Exception {
Connection conn = getConnection();
Statement st = conn.createStatement();
st = conn.createStatement();
String query = "INSERT INTO tbl_Hire" + " VALUES ( "+ S_id + ", "+ P_id +", "+ Rank +", '"+ Comment +"' )";
st.executeUpdate(query);
st.close();
public static void main(String[] args) throws Exception {
try
{
Connection conn = getConnection();
EndOfHire(1111, 1111, 8, "gfdg");
conn.close();
}
catch(SQLException ex) {
System.err.print("SQLException: ");
System.err.println(ex.getMessage());
}