我遇到了一些关于从 MS 访问数据库检索数据的问题

I am getting some issues regarding retrieving data from ms access database

我正在尝试从数据库中检索数据,但遇到了一些问题。 这是我的代码:

  {
        try
         {
Connection conn=DriverManager.getConnection("jdbc:ucanaccess://F:\Realestate\real estate.accdb");
Statement st=conn.createStatement();
String sql="select Property type,Property owner from property where Property type='"+searchbyidfld.getText()+"'and Property owner='"+searchbynamefld.getText()+"'";
ResultSet rs=st.executeQuery(sql);
if(rs.next())
{
  String retrieve=rs.getString("Property type");
  System.out.println(retrieve);
 }
  }
catch(Exception ex)
 {
   JOptionPane.showMessageDialog(null,"No record found");                                           
   }
   }

我还在 URL 中提供了正确的数据库路径。 这是我试图从中检索数据的数据库 我不知道我做错了什么。

这里是堆栈跟踪:

net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::3.0.6 user lacks privilege or object not found: PROPERTY
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::3.0.6 user lacks privilege or object not found: PROPERTY
    at net.ucanaccess.jdbc.UcanaccessStatement.executeQuery(UcanaccessStatement.java:211)
    at real.estate.Loginbtn.actionPerformed(Loginbtn.java:1691)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6535)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6300)

在你的代码中试试这个 String sql="select [Property type],[Property owner] from property where [Property type]='"+searchbyidfld.getText()+"'and [Property owner]='"+searchbynamefld.getText()+"'"; 包含空格的列名应该用正方形括起来 brackets.I 希望这对你有用