conn = Connect.ConnectDB();
String sql = "insert into Ianouarios ("
+"id,"
+"Hmerominia,"
+"Agores,"
+"Pliromes,"
+"Eksoda,"
+ "Zhta,"
+"Metaforika,"
+"Pliromimetafo,"
+"Epitages,"
+"Xondriki,"
+"Noiki,"
+"Plirominoiki)"
+ "values("+a1.getText()+ ",'"+a2.getText()+"','"+a3.getText()+"','"+a4.getText()+"','"+a5.getText()+"','"+a6.getText()+"','"+a7.getText()+"','"+a8.getText()+"','"+a9.getText()+"','"+ a10.getText()+ "','"+a11.getText()+"','"+a12.getText()+"')" ;
try{
pst = conn.prepareStatement(sql);
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Saved");
//UpdateJTable();
//conn.close();
}catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
I have an ms access database and i am updating it with the jdbc-odbc driver.
Can anyone show me how to do the same to work with ucanaccess driver?
I tried their ucanaccess page examples but no luck.
Update: I did this:
conn = Connect.ConnectDB();
try{
String sql = "INSERT INTO Synola(id,Hmerominia,Agores,Pliromes,Eksoda,Zhta,Metaforika,Pliromimetafo,Epitages,Xondriki,Noiki,Plirominoiki) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)" ;
/* SimpleDateFormat ddmmyyyyFormat = new SimpleDateFormat("dd/MM/yyyy");
Timestamp ddmmyyyy = new Timestamp(ddmmyyyyFormat.parse(a2.getText()).getTime()); */
// String s=ddmmyyyy.toString();
pst = conn.prepareStatement(sql);
pst.setString(1, a1.getText());
pst.setString(2,a2.getText());
pst.setString(3, a3.getText());
pst.setString(4, a4.getText());
pst.setString(5, a5.getText());
pst.setString(6, a6.getText());
pst.setString(7, a7.getText());
pst.setString(8, a8.getText());
pst.setString(9, a9.getText());
pst.setString(10, a10.getText());
pst.setString(11, a11.getText());
pst.setString(12, a12.getText());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Saved");
//UpdateJTableSynola();
// conn.close();
}catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
And now the problem is the date from the a2.getText() field which i put into database as (dd/MM/yyyy).The error is unparseable date.How can i fix this?