我想通过名称搜索产品,并在java的JTextField中显示名称和售价

我想通过名称搜索产品,并在java的JTextField中显示名称和售价,java,sql,database,Java,Sql,Database,这是我收到的错误消息: String sql = "SELECT * FROM posdb.products WHERE products.product_name = ?"; PreparedStatement ps = myCon.CreateConnection().prepareStatement(sql); 当您使用预处理的报表时,是否需要替换每个报表?在执行实际查询之前使用有效值 因此,代码的基础是: You have an error in your sql statement,

这是我收到的错误消息:

String sql = "SELECT * FROM posdb.products WHERE products.product_name = ?";
PreparedStatement ps = myCon.CreateConnection().prepareStatement(sql);
当您使用预处理的报表时,是否需要替换每个报表?在执行实际查询之前使用有效值

因此,代码的基础是:

You have an error in your sql statement, check the manual that 
  corresponds to your MariaDB server version for the right 
  syntax to use near '?' at line 1

请以代码格式文本的形式发布错误消息和代码。否则,我们很难复制、粘贴并尝试运行它。由于防火墙的限制,这里的一些人也看不到图像。另外,请在您的问题中加入更多细节,包括解释性文本和背景信息-任何有助于我们更好地理解您的代码、问题和问题的内容。请仔细阅读。这是错误消息。如果sql语句中有错误,请检查与您的MariaDB服务器版本相对应的手册,以便在第1行的“?”附近使用正确的语法,该行可能重复
You have an error in your sql statement, check the manual that 
  corresponds to your MariaDB server version for the right 
  syntax to use near '?' at line 1
String sql = "Select * from SomeTable where SomeColumn = ?";

PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, someColumnVariable);

ResultSet rs = stmt.executeQuery();