Insert

7 respostas
D

Pessoal, vê se vcs conseguem achar algum erro nesse código:

try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection db_novo_usuario = DriverManager.getConnection("jdbc:mysql://10.2.1.243/acesso", "root", ""); 
        Statement sq_stmt_novo_usuario = db_novo_usuario.createStatement(); 
        sq_stmt_novo_usuario.execute("INSERT INTO cont_acesso USUARIO VALUES "+textoacessoadministrador.getText());
    }catch(Exception e){
        System.out.println(e);
        return;
    }

está me retornando o seguinte erro:
java.sql.SQLException: Syntax error or access violation message from server: “Yo
u have an error in your SQL syntax. Check the manual that corresponds to your M
ySQL server version for the right syntax to use near 'USUARIO VALUES sadsdsdsa’
at line 1”

7 Respostas

R

Cara tente por em aspas duplas depois do VALUES

Flw…

R

Cara, analisando melhor

Faz assim

E desconsidere meu outro post :oops:

Abraços, :wink:

D

dessa forma continuou dando o mesmo erro, veja só:

java.sql.SQLException: Syntax error or access violation message from server: “Yo
u have an error in your SQL syntax. Check the manual that corresponds to your M
ySQL server version for the right syntax to use near ‘USUARIO VALUES (‘dfdfdfdf’
)’ at line 1”

R

Vc pos o USUARIO assim (USUARIO) ?

D

ok amigo, agora funcionou perfeitamente.

muito obrigado pela ajuda.

D

amigo, agora estou tendo problema na instrução DELETE.

sq_stmt_novo_usuario.execute(“DELETE * FROM cont_acesso where USUARIO=”+"’"+usuario_acesso_administrador+"’");

java.sql.SQLException: Syntax error or access violation message from server: “Yo
u have an error in your SQL syntax. Check the manual that corresponds to your M
ySQL server version for the right syntax to use near ‘* FROM cont_acesso where U
SUARIO=‘dfdffdfdsfsd’’ at line 1”

o que pode ser?

R

Tire o *

Flw

Criado 28 de setembro de 2004
Ultima resposta 28 de set. de 2004
Respostas 7
Participantes 2