skip to Main Content

I use MySQL, why MariaDB in the error message? I’m trying to load some data from my databasetable into my table but I’m having this error, even though I did use prepared statements to call executeQuery without passing any parameter

 public void Category_Load()
{

    int c;
    
    try {
                    //The issue is here
        pst = con.prepareStatement("select * form category= ?");
        rs = pst.executeQuery();
        
        ResultSetMetaData rsd = rs.getMetaData();
        c = rsd.getColumnCount();
        
        
        DefaultTableModel d = (DefaultTableModel)jTable1.getModel();
        d.setRowCount(0);
        
        
        while(rs.next())
        {
        
            Vector v2 = new Vector();
            
            for(int i= 1; i<=c; i++)
            {
            
                v2.add(rs.getString("id"));
                v2.add(rs.getString("catname"));
                v2.add(rs.getString("status"));
            }
            
            d.addRow(v2);
            
        }    
        
        
        
    } catch (SQLException ex) {
        Logger.getLogger(Category.class.getName()).log(Level.SEVERE, null, ex);
    }

    
    
    
}     

here the error statement

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘form category’ at line 1

2

Answers


  1. You have a typo in your query.

    select * form category= ?
    

    should be

    select * from category= ?
    
    Login or Signup to reply.
  2. The other answer is correct, you have an error because you misspelled a keyword in your SQL query. But that’s not the question you asked.

    I use MySQL, why MariaDB in the error message?

    MySQL Server will not mention MariaDB in its error message. MySQL and MariaDB are different products. Therefore if your error message reports MariaDB, then this is evidence that you are using MariaDB Server, not MySQL Server.

    The syntax error message is reported by the database server. That’s where syntax checking is done. It’s possible to use a MySQL client to connect to either a MySQL Server or a MariaDB Server. At least for current versions (MySQL 8.0 and MariaDB 10.6 are current), the client/server protocol is compatible (they may not always be compatible in future versions, since both products are evolving).

    Try the query SELECT VERSION(); to check the version of the database server you are using.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search