I am using MS Access 07, I already made the Connection with ODBC. In my code I am having problems with "executeUpdate". I don't know why. Does someone can help me with that? Thanks!!
import java.sql.*;
import java.beans.Statement;
public void Conexao()
{
try {
//1 passo - carregar o driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//2 passo - criar a conexao de banco
con = DriverManager.getConnection("jdbc: odbc: DNSWiki");
//3 passo - criar o obejto que manipula a rotina sql
st = (Statement) con.createStatement();
} catch (Exception e) {
}
}
//// -------- I am using a JMenuItem (Save) ---------///
private void SaveActionPerformed(java.awt.event.ActionEvent evt) {
try{
Conexao();
String ss = ssnT.getText();
String Fname = FNT.getText();
String Lname = LNT.getText();
String Mname = MNT.getText();
String address = AddressT.getText();
String city = CityT.getText();
String state = StateT.getText();
String zipcode = ZipCodeT.getText();
String phone = PhoneT.getText();
String email = EmailT.getText();
String birthday = BirthdayT.getText();
String country = CountryT.getText();
int i = st.executeUpdate("insert into tbWiki values('"+ ss +"','"+Fname+"','"+Lname+"','"+Mna me+"','" + address + "','" + city + "','"+ state +"','"+zipcode+"','"+country+"', '"+ phone +"','"+email+"','"+birthday+"')");
JOptionPane.showMessageDialog(null, "Dados inseridos com sucesso!");
con.close();
}
catch ( Exception ex )
{
JOptionPane.showMessageDialog(null, "Esse Cpf já está cadastrado! ");
} // end catch
}