Eu tenho um banco de dados criado e fiz a conexão usando o driver JDBC. O problema é que quando uso o comando Insert, ele lança um SQLException. A conexão vai bem, é só o comando mesmo que da erro.
Classe de conexão
[code]public class DbCon
{
private Connection con;
public DbCon()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
this.con = DriverManager.getConnection(
"jdbc:mysql://localhost/reposicaopecas?user=root&password=123");
} catch (ClassNotFoundException ex)
{
javax.swing.JOptionPane.showMessageDialog(null, "Constr ClassNotFoundException");
} catch (SQLException ex)
{
javax.swing.JOptionPane.showMessageDialog(null, "Constr SQLException");
}
}
public void cadastrarFornecedor(String nf, String razs, String cidade, String uf,
String cep, String endereco, int numero, String bairro, String cnpj, String ie,
String e1, String e2, String t1, String t2)
{
try
{
String com = "INSERT INTO fornecedor (nome_fantasia, razao_social, cidade, uf, cep,"
+ " endereco, numero, bairro, cnpj, inscricao_estadual, email1, email2, telefone1, telefone2)"
+ " VALUES(" + nf + ", " + razs + ", " + cidade + ", " + uf + ", " + cep + ", " + endereco
+ ", " + numero + ", " + bairro + ", " + cnpj + ", " + ie + ", " + e1 + ", " + e2 + ", "
+ t1 + ", " + t2 + ")";
Statement stm = this.con.createStatement();
int rs = stm.executeUpdate(com);
stm.close();
this.con.close();
javax.swing.JOptionPane.showMessageDialog(null, "Cadastro efetuado com sucesso");
}catch(SQLException ex)
{
javax.swing.JOptionPane.showMessageDialog(null, "cadastrarFornec SQLException");
}
}
}[/code]
public void mouseClicked(MouseEvent e)
{
DbCon c = new DbCon();
int num = Integer.parseInt(txtNum.getText());
c.cadastrarFornecedor(txtNFant.getText(),
txtRazSoc.getText(),
txtCidade.getText(),
cbUf.getEditor().getItem().toString(),
ftxtCep.getText(),
txtEndereco.getText(),
num,
txtBairro.getText(),
ftxtCnpj.getText(),
ftxtIE.getText(),
txtEmail1.getText(),
txtEmail2.getText(),
ftxtTel1.getText(),
ftxtTel2.getText());
}
O que eu to fazendo de errado? =/