【发布时间】:2016-03-04 19:20:39
【问题描述】:
我正在使用 JDBC 驱动程序围绕 MySQL 数据库构建一个程序。 我被困在这一点上。
loginWindow lW = new loginWindow();
try {
PreparedStatement pst = connHandler.conn.prepareStatement("SELECT * FROM '" + lW.fieldUname.getText() + "''");
ResultSet rs = pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
} catch (SQLException e) {
e.printStackTrace();
}
我有一个 connHandler 类,它保存着连接方法和 Connection(命名为:“conn”)变量。我假设我的查询有一些问题。
我得到的错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near ''''' at line 1
非常感谢任何帮助或建议。
【问题讨论】: