SQL command not ended properly
<p>I try to make a code in java that accesses some tables from sql but when I try to run the code I get an error saying:</p>

<blockquote>
  <p>java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly
  ended</p>
</blockquote>

<p>Here is the code that it's been giving me troubles: </p>

<pre><code>history.addActionListener(new ActionListener()
{
    @Override
    public void actionPerformed(ActionEvent actionEvent)
    {
        for(int i = 0; i &lt; table.getRowCount(); i++)
            for(int j = 0; j &lt; table.getColumnCount(); j++)
                table.setValueAt("", i, j);

        int i=0;
        try
        {
            rs = stmt.executeQuery("SELECT toyname, toyid, price "
                    +" FROM toys t, userbuy u " 
                                                +" WHERE u.toyid=t.toyid "
                    +" AND u.userid= "+user1.getUserid()+" )");
        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }
        finally
        {
            try {
                if(rs.next())
                {
                    table.setValueAt(rs.getString(1), i, 0);
                    table.setValueAt(rs.getString(2), i, 1);
                    table.setValueAt(rs.getString(3), i, 2);
                    i++;
                    while(rs.next())
                    {
                        table.setValueAt(rs.getString(1), i, 0);
                        table.setValueAt(rs.getString(2), i, 1);
                        table.setValueAt(rs.getString(3), i, 2);
                        i++;
                    }
                }
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(null, e.getMessage());
            }
        }
    }
});
</code></pre>

<p>Those are my two tables:</p>

<pre><code>CREATE TABLE users
(
  userid    NUMBER(2) NOT NULL CONSTRAINT users_pk PRIMARY KEY,
  username        VARCHAR(17) NOT NULL,
  password    VARCHAR(20),
  email   VARCHAR(20),
  adress    VARCHAR(20),
  CNP     VARCHAR(14)
);
CREATE TABLE userbuy
(
  userid    NUMBER(2),
  buyid    NUMBER(2) ,
  toyid NUMBER(2),
  CONSTRAINT userid_fk FOREIGN KEY (userid) REFERENCES users(userid),
  CONSTRAINT buyid_fk FOREIGN KEY (buyid) REFERENCES buy(buyid)
);
</code></pre>

<p>Does anyone know what is wrong here?</p>