简体   繁体   English

线程“主”java.sql.SQLException 中的异常:未找到适合 jdbc:ucanaccess://C:/Users/gfas1/acctop/.

[英]Exception in thread “main” java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:/Users/gfas1/Desktop/st.accdb

So I'm trying to set up the connection in access database but otherwise fails.所以我试图在访问数据库中建立连接,但否则失败。 I have imported the ucanaccess 5 files already and I'm confused why this doesn't work.我已经导入了 ucanaccess 5 个文件,我很困惑为什么这不起作用。 Here are the jars这里是 jars

public class Access {

public static void main(String[] args) throws ClassNotFoundException, SQLException {
    // TODO Auto-generated method stub


        Connection conn=DriverManager.getConnection("jdbc:ucanaccess://C:/Users/gfas1/Desktop/st.accdb");
        Statement stment = conn.createStatement();
        String qry = "SELECT * FROM Students";

        ResultSet rs = stment.executeQuery(qry);
        while(rs.next())
        {
            String id    = rs.getString("ID") ;
            String fname = rs.getString("Name");

            System.out.println(id + fname);
        }
    }



} 

JDBC driver should be loaded and you should have driver jar in your classpath应该加载 JDBC 驱动程序,并且您的类路径中应该有驱动程序 jar

Class.forName("net.ucanaccess.jdbc.UcanaccessDriver"); Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");

In this case driver registers itself and Java knows how to handle those database connection.在这种情况下,驱动程序会自行注册,并且 Java 知道如何处理这些数据库连接。

also see http://ucanaccess.sourceforge.net/site.html另见http://ucanaccess.sourceforge.net/site.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 例外:java.sql.SQLException:没有为jdbc找到合适的驱动程序:ucanaccess - Exception: java.sql.SQLException: No suitable driver found for jdbc:ucanaccess 线程“ main”中的异常java.sql.SQLException:找不到适合的驱动程序 - Exception in thread “main” java.sql.SQLException: No suitable driver found for 我正面临java.sql.SQLException:没有为jdbc找到合适的驱动程序:ucanaccess:// C:/ - I am facing java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:/ Exception in thread "AWT-EventQueue-0" java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/gestaocondominio - Exception in thread "AWT-EventQueue-0" java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/gestaocondominio java.sql.SQLException:找不到适用于jdbc:sqlserver://的驱动程序 - java.sql.SQLException: No suitable driver found for jdbc:sqlserver:// java.sql.SQLException:找不到适合jdbc:oracle:thin的驱动程序 - java.sql.SQLException: No suitable driver found for jdbc:oracle:thin java.sql.SQLException:找不到适用于jdbc:derby的驱动程序: - java.sql.SQLException: No suitable driver found for jdbc:derby: java.sql.SQLException:找不到适用于jdbc:mysql的驱动程序 - java.sql.SQLException: No suitable driver found for jdbc:mysql java.sql.SQLException:找不到适用于jdbc:sqlserver的驱动程序: - java.sql.SQLException: No suitable driver found for jdbc:sqlserver: java.sql.SQLException:没有找到适合 jdbc:microsoft:sqlserver 的驱动程序 - java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM