Ucanaccess SQL Exception: feature not supported (Access and Netbeans)

China☆狼群 提交于 2020-05-09 05:26:05

问题


I've been researching this problem for days and have decided to ask this question here to see if anyone can help point me in the right direction.

I'm trying to populate combo boxes in my Netbeans 8.0.2 program with data from an MS Access 2013 table.

I'm using the most recent "Ucanaccess" with all of its necessary components to get the connection between the two, and from what I can tell the connection is good. However, when I run the program, it pops up an error exception message, reading:

net.ucanaccess.jdbc.UcanaccessSQLException: feature not supported

And that's it - no other letters, characters, numbers... nothing.

I'm honestly lost. Does anyone have any idea why I might be receiving this exception message?

Also, I'm running this on a Mac, however I use parallels and am actually running it on Microsoft Windows 7 virtual platform. It hasn't given me any trouble at all since then. 64 bit.

Here's what I've got coded.

import java.sql.*;
import javax.swing.*;

public class NewJFrame extends javax.swing.JFrame {
    Connection conn = null;
    ResultSet rs = null;
    PreparedStatement pst = null;

    private void FillCombo() {
        String sql = "Select [Description] from [Doors]";
        try {
            String driver = "net.ucanaccess.jdbc.UcanaccessDriver";
            Class.forName(driver);
            conn = DriverManager.getConnection("jdbc:ucanaccess://C:/Test/DB.accdb");
            pst = conn.prepareStatement(sql);
            rs = pst.executeQuery(sql);

            while (rs.next()) {
                String nme = rs.getString("Description");
                cmb1.addItem(nme);
            }
            conn.close();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,e);
        }            
    }

    /**
     * Creates new form NewJFrame
     */
    public NewJFrame() {
        initComponents();
        FillCombo();            
    }

Updated:

net.ucanaccess.jdbc.UcanaccessSQLException: feature not supported
    at net.ucanaccess.jdbc.UcanaccessStatement.executeQuery(UcanaccessStatement.java:202)
    at NewJFrame.FillCombo(NewJFrame.java:26)
    at NewJFrame.<init>(NewJFrame.java:50)
    at NewJFrame$2.run(NewJFrame.java:117)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.sql.SQLFeatureNotSupportedException: feature not supported
    at org.hsqldb.jdbc.JDBCUtil.notSupported(Unknown Source)
    at org.hsqldb.jdbc.JDBCPreparedStatement.executeQuery(Unknown Source)
    at net.ucanaccess.jdbc.UcanaccessStatement.executeQuery(UcanaccessStatement.java:199)
    ... 17 more

回答1:


You need to call PreparedStatement#executeQuery() not PreparedStatement#executeQuery(String)



来源:https://stackoverflow.com/questions/31396919/ucanaccess-sql-exception-feature-not-supported-access-and-netbeans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!