3 Replies Latest reply on Jan 4, 2004 7:08 PM by Sergio

    JBOSS3.2 and MySQL4.0 insert exception

    Sergio Newbie

      I am a newbie and I have created a datasource connection to MySQL database using the example provided by Jboss, I have written an ejb and I create a connection and run a select statement fine, the problem is that when I run an insert statement Jboss gives me this exception message, I am sure my sql statement is fine I ran it in MySql console, and it works fine.
      Any help is greatly appreciated.
      Thanks

      13:34:17,535 INFO [STDOUT] SQL: INSERT INTO usr(usr_handle,usr_passwd,usr_fname,usr_lname,usr_desc,usr_status)values('gbarreros','testpwd','testname','testlname','testdexc','active')
      13:34:17,547 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@1e4dbfb
      java.lang.Exception: STACKTRACE
      at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:282)
      -bash: 13:34:17,533: command not found
      swat:/usr/local/jboss3.2.2/bin # 13:34:17,535 INFO [STDOUT] SQL: INSERT INTO usr(usr_handle,usr_passwd,usr_fname,usr_lname,usr_desc,usr_status)values('gbarreros','testpwd','testname','testlname','testdexc','active')
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:506)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # 13:34:17,536 INFO [STDOUT] from adder Bean
      -bash: 13:34:17,536: command not found
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:814)
      swat:/usr/local/jboss3.2.2/bin # 13:34:17,547 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@1e4dbfb
      -bash: 13:34:17,547: command not found
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)
      swat:/usr/local/jboss3.2.2/bin # java.lang.Exception: STACKTRACE
      -bash: java.lang.Exception:: command not found
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:282)
      -bash: syntax error near unexpected token `('
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:506)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:814)
      -bash: syntax error near unexpected token `('
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at com.sgb.ejb.AdderBean.add(AdderBean.java:27)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      -bash: syntax error near unexpected token `('
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:144)
      at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
      swat:/usr/local/jboss3.2.2/bin # at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at java.lang.reflect.Method.invoke(Method.java:324)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:144)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      -bash: syntax error near unexpected token `('
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      -bash: syntax error near unexpected token `('
      at java.lang.reflect.Method.invoke(Method.java:324)
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.ejb.Container.invoke(Container.java:700)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      -bash: syntax error near unexpected token `('
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
      swat:/usr/local/jboss3.2.2/bin # at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      -bash: syntax error near unexpected token `('
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      swat:/usr/local/jboss3.2.2/bin # at java.lang.reflect.Method.invoke(Method.java:324)
      -bash: syntax error near unexpected token `('
      at java.lang.reflect.Method.invoke(Method.java:324)
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      -bash: syntax error near unexpected token `('
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      -bash: syntax error near unexpected token `('
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      swat:/usr/local/jboss3.2.2/bin # at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
      -bash: syntax error near unexpected token `('
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      swat:/usr/local/jboss3.2.2/bin # at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at java.lang.reflect.Method.invoke(Method.java:324)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.rmi.transport.Transport$1.run(Transport.java:148)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at java.security.AccessController.doPrivileged(Native Method)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      -bash: syntax error near unexpected token `('
      swat:/usr/local/jboss3.2.2/bin # at java.lang.Thread.run(Thread.java:534)
      -bash: syntax error near unexpected token `('

        • 1. Re: JBOSS3.2 and MySQL4.0 insert exception
          James Black Newbie

          You should have a space between ')' and values.

          • 2. Re: JBOSS3.2 and MySQL4.0 insert exception
            Sergio Newbie

            Thanks for the fast response, but I have tried tweeking my sql statement a lot and nothing worked, that is why I don't think the problem is my sql statement. Here is my datasource xml file , and I've tried using these two
            Drivers
            org.gjt.mm.mysql.Driver
            com.mysql.jdbc.Driver


            <local-tx-datasource>
            <jndi-name>BARREROS</jndi-name>
            <connection-url>jdbc:mysql://localhost:3306/BARREROS</connection-url>
            <driver-class>org.gjt.mm.mysql.Driver</driver-class>
            <user-name>myusername</user-name>
            mypasswd
            </local-tx-datasource>


            ================================================
            This is how my ejb looks

            Statement stmt;
            String sql = "INSERT INTO usr"+
            "(usr_handle,usr_passwd,usr_fname,usr_lname,usr_desc,usr_status)"+
            " values ('gbarreros','testpwd','testname','testlname','testdexc','active')";
            try {
            Context ctx = new InitialContext();
            DataSource ds = (DataSource)ctx.lookup("java:/BARREROS");
            Connection con = ds.getConnection();
            stmt = con.createStatement();
            stmt.executeQuery(sql);
            /*if(rs.next()){
            System.out.println(rs.getString(1));
            }*/
            ctx.close();
            con.close();
            } catch (javax.naming.NamingException _ne) {
            System.out.println("DataSource: Naming Exception!");
            } catch (java.sql.SQLException _se) {
            System.out.println("SQL Exception");
            System.out.println("SQL: " + sql);
            } finally {

            }


            Thanks for all advise

            • 3. Found the problem
              Sergio Newbie

              It seems that for Mysql I need to use stmt.executeUpdate(sql) instead of stmt.executeQuery(sql) when doing an update,insert or delete statements.