Voce não está comitando a transação.
Acho que voce tem que usar o comando executeUpdate ao invés execute.
Talvez execute não tenha auto-commit.
Outra alterativa pode ser dar um commit explicito.
Tenta aí.
[]'s
Sergio
>From: Jean Carlo Mendes <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: [java-list] Probelma com Java x Access
>Date: Wed, 14 Mar 2001 20:09:09 -0300 (ART)
>
>Amigos da lista;
>
>Estou tentando inserir um registro em um BD Access e
>não estou conseguindo. A consulta funciona
>perfeitamente, porem a insercao de registro, apesar de
>nao gerar nenhum erro de compilacao e nem de execução,
>simplesmente não ocorre.
>Estou tentando inserir um registro na tabela TBLAMIGO,
>que possui os seguintes campos: CODAMI, NOMAMI,
>TELAMI, ENDELE, CELAMI. Sendo que esta tabela não
>possui Chave e todos os campos sao texto.
>Segue o codigo da classe e os metodos:
>
>------------------------------------------------------
>import java.sql.*;
>
>public class Amigo extends java.lang.Object {
>
> private String codigo = blank;
> private String nome = blank;
> private String fone = blank;
> private String celular = blank;
> private String email = blank;
> static Connection con = null;
> static private String blank = "";
> private int acao = 0;
>
> public Amigo() {
> if (con == null) {
> try {
>
>Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> con =
>DriverManager.getConnection("jdbc:odbc:BIBLIOTECA",
>"", "");
> } catch (Exception e) {
> System.err.println ("Erro no comando
>SQL de Conexao");
> }
> }
> }
>
> public String getNome() {
> return nome;
> }
>
> public void setNome(String nome) {
> this.nome = nome;
> }
>
> public String getCodigo() {
> return codigo;
> }
>
> public void setCodigo(String codigo) {
> this.nome = codigo;
> }
>
>
> public String getFone() {
> return fone;
> }
>
> public void setFone(String fone) {
> this.fone = fone;
> }
>
> public String getCelular() {
> return celular;
> }
>
> public void setCelular(String celular) {
> this.celular = celular;
> }
>
> public String getEmail() {
> return email;
> }
>
> public void setEmail(String email) {
> this.email = email;
> }
>
> public int getAcao() {
> return acao;
> }
>
> public void setAcao(int acao) {
> this.acao = acao;
> }
>
> public boolean fazAcao() {
> if (acao == 1) { // consultar
> try {
> Statement stmt =
>con.createStatement();
> ResultSet rs = stmt.executeQuery
>("SELECT * FROM TBLAMIGO WHERE NOMAMI LIKE '%" + nome
>+ "%'");
> if (rs.next()) {
> codigo = rs.getString(1);
> nome = rs.getString(2);
> fone = rs.getString(3);
> email = rs.getString(4);
> celular = rs.getString(5);
> }
> else {
> acao = 3;
> fazAcao();
> return false;
> }
>
> rs.close();
> stmt.close();
> }
> catch (Exception e) {
> System.err.println ("Erro no comando
>SQL de Consulta");
> return false;
> }
> }
> else if (acao == 2) { // Inserir
> try {
> Statement stmt =
>con.createStatement();
>
> stmt.execute ("INSERT INTO TBLAMIGO
>(NOMAMI, TELAMI, ENDELE, CELAMI)" +
> " VALUES (' "+ nome + "' , '" + fone +
>"' , '" + email + "' ,' " +
> celular + "' )" );
> stmt.close();
> }
> catch (Exception e) {
> System.err.println ("Erro no comando
>SQL de Insert");
> return false;
> }
> } else if (acao == 3) { // Limpar Campos
> nome = fone = celular = email = blank;
> }
> acao = 0;
> return true;
> }
>
> public static void main (String args[]) {
> Amigo a = new Amigo();
> a = new Amigo();
> a.setNome("Jean");
> a.setAcao(1);
> a.fazAcao();
> System.out.println ("Nome:" + a.getNome() +
>"\n" +
> "E-mail: " + a.getEmail()
>+ "\n" +
> "Celular:" + a.getCelular()+ "\n" +
> "Telefone:" + a.getFone()
>+ "\n" );
> Amigo b = new Amigo ();
> b.setNome("Fernanda");
> b.setEmail("[EMAIL PROTECTED]");
> b.setFone("322 444");
> b.setCelular("99454545");
> b.setAcao(2);
> b.fazAcao();
>
> }
>}
>-------------------------------------------------------
>
>Agradeco qualquer sugestao
>
>
>
>=====
>Jean Carlo Mendes
>
>________________________________________________________________________
>O YAHOO! GEOCITIES CHEGOU AO BRASIL!
>Crie sua home page com tudo em português - http://br.geocities.com
>
>------------------------------ LISTA SOUJAVA ----------------------------
>http://www.soujava.org.br - Sociedade de Usuários Java da Sucesu-SP
>dúvidas mais comuns: http://www.soujava.org.br/faq.htm
>regras da lista: http://www.soujava.org.br/regras.htm
>para sair da lista: envie email para [EMAIL PROTECTED]
>-------------------------------------------------------------------------
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
------------------------------ LISTA SOUJAVA ----------------------------
http://www.soujava.org.br - Sociedade de Usuários Java da Sucesu-SP
dúvidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
para sair da lista: envie email para [EMAIL PROTECTED]
-------------------------------------------------------------------------