Loading ...
Sorry, an error occurred while loading the content.

5075RES: [riojug] Re: Erro JDBC c/ SQL Server

Expand Messages
  • Gerson
    Dec 1, 2003
    • 0 Attachment
      Experimente colocar 2 no lugar de 1 na segunda linha, como segue:

      pstmt.setInt(1, vCodigoUsuario);
      pstmt.setInt(>>>>>2<<<, vCodigoEmpresa);

      Gerson

      ----- Mensagem original -----
      De: Leonardoacb [SMTP:leonardoacb@...]
      Enviada em: sabado, 29 de novembro de 2003 19:14
      Para: riojug@yahoogroups.com
      Assunto: Re: [riojug] Re: Erro JDBC c/ SQL Server

      Carlos,

      Continua o mesmo erro:
      Conexao: SQLException java.sql.SQLException: [Microsoft][SQLServer 2000
      Driver for JDBC]Invalid parameter binding(s).

      Vou enviar toda classe novamente.

      package com.jsistema.admin;

      import java.sql.*;
      import com.jsistema.admin.*;

      public class Auditoria {
      private ConnectionPool connectionPool;
      private Connection connection;
      private Statement statement;

      public void LogAudit(int vCodigoUsuario, int vCodigoEmpresa, int
      vCodigoRotina, int vCodigoModulo, String vMensagem, String vObservacao, String
      vIP) {
      int vCont = 0;
      try {
      try {
      connectionPool = new ConnectionPool();
      connection = connectionPool.getConnection();
      statement = connection.createStatement();
      }
      catch(SQLException e) {
      System.err.println("Conexao: Erro ao carregar pool: " + e);
      connectionPool = null;
      }

      String sql = "INSERT INTO log_audit (codigo_usuario, codigo_empresa,
      mensagem, observacao, ip) VALUES (?, ?, 'Usuario Logado!', 'Empresa: 0001 /
      Login: admin', '127.0.0.1')";

      try {
      PreparedStatement pstmt = connection.prepareStatement(sql);

      pstmt.setInt(1, vCodigoUsuario);
      pstmt.setInt(1, vCodigoEmpresa);

      pstmt.executeUpdate();
      }
      catch (SQLExeption e) {
      System.err.println("Conexao: SQLException " + e);
      }
      }
      ----- Original Message -----
      From: carlosrguti
      To: riojug@yahoogroups.com
      Sent: Friday, November 28, 2003 3:51 PM
      Subject: [riojug] Re: Erro JDBC c/ SQL Server



      Mais uma coisa que percebi agora. Quando vc quer realizar um insert,
      delete ou update usa-se o pstmt.executeUpdate(). O executeQuery e so
      para "SELECT"

      Valeu?


      --- In riojug@yahoogroups.com, "carlosrguti" <carlos.jug@i...> wrote:
      > E o espaco antes do VALUES???
      >
      > Aparentemente esta tudo certo, tb tenta substituir a linha:
      >
      > PreparedStatement pstmt = conexao.preparaQuery(sql);
      >
      > por
      >
      > PreparedStatement pstmt = conexao.prepareStatement(sql);
      >
      >
      >
      >
      >
      > --- In riojug@yahoogroups.com, "Leonardoacb" <leonardoacb@b...>
      wrote:
      > > Nao Ricardo,
      > >
      > > O "I" so esta faltando no e-mail. foi um erro na hora de
      > copiar.
      > >
      > > ----- Original Message -----
      > > From: ricardo.falter@h...
      > > To: riojug@yahoogroups.com
      > > Sent: Thursday, November 27, 2003 9:50 AM
      > > Subject: Re: [riojug] Erro JDBC c/ SQL Server
      > >
      > >
      > >
      > >
      > >
      > >
      > > Nao estaria faltando o "I" no INSERT?
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > > |---------+---------------------------->
      > > | | "Leonardoacb" |
      > > | | <leonardoacb@brfr|
      > > | | ee.com.br> |
      > > | | |
      > > | | 27/11/2003 00:19 |
      > > | | Please respond to|
      > > | | riojug |
      > > | | |
      > > |---------+---------------------------->
      > > >-------------------------------------------------------------
      --
      > -----------------------------------------------|
      > >
      >
      |
      > |
      > > | To:
      >
      <riojug@yahoogroups.com>
      > |
      > > |
      >
      cc:
      > |
      > > | Subject: [riojug] Erro JDBC c/ SQL
      > Server |
      > > >-------------------------------------------------------------
      --
      > -----------------------------------------------|
      > >
      > >
      > >
      > >
      > > ____________________________________________ Did you know that
      > you could
      > > earn money with Dot TK? It's simple. Become an affiliate today
      > and promote
      > > Dot TK on your website! http://www.dot.tk/vc00804.html
      > > ____________________________________________
      > > Alguem ja viu esse erro???
      > >
      > > javax.servlet.ServletException: [Microsoft][SQLServer 2000
      > Driver for
      > > JDBC]Invalid parameter binding(s).
      > >
      > > O meu codigo esta assim:
      > >
      > > Conexao conexao = new Conexao();
      > >
      > > String sql = "NSERT INTO log_audit (codigo_usuario,
      > codigo_empresa,
      > > mensagem, observacao, ip)VALUES (?, ?, ?, ?, ?)";
      > >
      > > PreparedStatement pstmt = conexao.preparaQuery(sql);
      > >
      > > pstmt.setInt(1, vCodigoUsuario);
      > > pstmt.setInt(2, vCodigoEmpresa);
      > > pstmt.setString(3, vMensagem);
      > > pstmt.setString(4, vObservacao);
      > > pstmt.setString(5, vIP);
      > >
      > > ResultSet result = pstmt.executeQuery();
      > >
      > >
      > > Yahoo! Groups Sponsor
      > >
      > >
      > >
      > > ADVERTISEMENT
      > > click here
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      > > Participe tambem das outras listas do RioJUG:
      > > JS Faces - RioJUG (http://groups.yahoo.com/group/jsf_riojug/)
      > > SCJP - RioJUG (http://groups.yahoo.com/group/scjp_riojug)
      > > SCWCD - RioJUG (http://groups.yahoo.com/group/scwcd_riojug)
      > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      > > Rio Java User's Group (grupo oficial da SUCESU-RJ)
      > >
      > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      > > Nosso site: http://www.riojug.org
      > > Informacoes: http://groups.yahoo.com/group/riojug
      > > Enviar mensagens: riojug@yahoogroups.com
      > > Inscrever-se no grupo: riojug-subscribe@yahoogroups.com
      > > Retirar-se do grupo: riojug-unsubscribe@yahoogroups.com
      > > Falar com o Moderador: riojug-owner@yahoogroups.com
      > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      > >
      > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      > Service.
      > >
      > >
      > >
      > > Yahoo! Groups Sponsor
      > >
      > >
      > >
      > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      > > Participe tambem das outras listas do RioJUG:
      > > JS Faces - RioJUG (http://groups.yahoo.com/group/jsf_riojug/)
      > > SCJP - RioJUG (http://groups.yahoo.com/group/scjp_riojug)
      > > SCWCD - RioJUG (http://groups.yahoo.com/group/scwcd_riojug)
      > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      > > Rio Java User's Group (grupo oficial da SUCESU-RJ)
      > >
      > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      > > Nosso site: http://www.riojug.org
      > > Informacoes: http://groups.yahoo.com/group/riojug
      > > Enviar mensagens: riojug@yahoogroups.com
      > > Inscrever-se no grupo: riojug-subscribe@yahoogroups.com
      > > Retirar-se do grupo: riojug-unsubscribe@yahoogroups.com
      > > Falar com o Moderador: riojug-owner@yahoogroups.com
      > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      > >
      > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      > Service.


      Yahoo! Groups Sponsor
      ADVERTISEMENT




      -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      Participe tambem das outras listas do RioJUG:
      JS Faces - RioJUG (http://groups.yahoo.com/group/jsf_riojug/)
      SCJP - RioJUG (http://groups.yahoo.com/group/scjp_riojug)
      SCWCD - RioJUG (http://groups.yahoo.com/group/scwcd_riojug)
      -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      Rio Java User's Group (grupo oficial da SUCESU-RJ)

      -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      Nosso site: http://www.riojug.org
      Informacoes: http://groups.yahoo.com/group/riojug
      Enviar mensagens: riojug@yahoogroups.com
      Inscrever-se no grupo: riojug-subscribe@yahoogroups.com
      Retirar-se do grupo: riojug-unsubscribe@yahoogroups.com
      Falar com o Moderador: riojug-owner@yahoogroups.com
      -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
      << Arquivo: ATT00016.html >>