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:Baby SitterAgency";
String username = "";
String password = "zsczd";
try{
Class.forName(d river);}
catch(java.lang .ClassNotFoundE xception e) {
System.err.prin t("ClassNotFoun dException: ");
System.err.prin tln(e.getMessag e()); }
return DriverManager.g etConnection(ur l, username, password);
}
public static void EndOfHire(int S_id, int P_id, float Rank, String Comment)throws Exception {
Connection conn = getConnection() ;
Statement st = conn.createStat ement();
st = conn.createStat ement();
String query = "INSERT INTO tbl_Hire" + " VALUES ( "+ S_id + ", "+ P_id +", "+ Rank +", '"+ Comment +"' )";
st.executeUpdat e(query);
st.close();
public static void main(String[] args) throws Exception {
try
{
Connection conn = getConnection() ;
EndOfHire(1111, 1111, 8, "gfdg");
conn.close();
}
catch(SQLExcept ion ex) {
System.err.prin t("SQLException : ");
System.err.prin tln(ex.getMessa ge());
}
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:Baby SitterAgency";
String username = "";
String password = "zsczd";
try{
Class.forName(d river);}
catch(java.lang .ClassNotFoundE xception e) {
System.err.prin t("ClassNotFoun dException: ");
System.err.prin tln(e.getMessag e()); }
return DriverManager.g etConnection(ur l, username, password);
}
public static void EndOfHire(int S_id, int P_id, float Rank, String Comment)throws Exception {
Connection conn = getConnection() ;
Statement st = conn.createStat ement();
st = conn.createStat ement();
String query = "INSERT INTO tbl_Hire" + " VALUES ( "+ S_id + ", "+ P_id +", "+ Rank +", '"+ Comment +"' )";
st.executeUpdat e(query);
st.close();
public static void main(String[] args) throws Exception {
try
{
Connection conn = getConnection() ;
EndOfHire(1111, 1111, 8, "gfdg");
conn.close();
}
catch(SQLExcept ion ex) {
System.err.prin t("SQLException : ");
System.err.prin tln(ex.getMessa ge());
}