抛出java.lang.ClassNotFoundException:org.postgresql.Driver,机器人 [英] java.lang.ClassNotFoundException: org.postgresql.Driver, Android

查看:765
本文介绍了抛出java.lang.ClassNotFoundException:org.postgresql.Driver,机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上运行Eclipse。

I am running Eclipse on Windows.

本教程我下载JDBC4,把它添加到项目使用我的构建路径>属性>添加外部JAR,浏览的文件,它的工作(的.classpath 文件显示了正确的库路径)。

Following this tutorial I downloaded JDBC4, added it to my build path using Project>Properties>add External JAR, browsed for the file, it worked (.classpath file shows the correct lib path).

包出现在我引用的库文件夹,所以我继续教程。

The package appears in my Referenced Libraries folder, so I continue the tutorial.

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;

    ....

    public void open ()
        {
    try {
        Class.forName("org.postgresql.Driver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

    try {
        conn = DriverManager.getConnection(url, username, password);
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

我认为这将是如此简单,但我会碰到一个大长今堆栈跟踪开始

I think it would be as simple as that but I get hit with this big long stack trace starting with

    java.lang.ClassNotFoundException: org.postgresql.Driver

(如果需要,我可以提供更多的)

(I can provide more if needed)

我试过包括org.postgresql *; 但这并没有帮助。我也曾尝试JDBC3,但没有运气有两种。

I tried include org.postgresql.*; but that didn't help either. I have also tried the JDBC3 but no luck there either.

我看着驱动JDBC PostgreSQL在这提供了一个模糊的回答说:我的Andr​​oid 只是使用HTTP + JSON会更好。这是我从来没有使用过。

I looked at Driver JDBC PostgreSQL with Android which provided a vague answer saying I would be better off just using HTTP+JSON. Which I have never used.

我是全新到Android和PostgreSQL,网络的发展,因此一个简单的答案是AP preciated。

I'm brand new to Android, postgresql, web development, so a simple answer would be appreciated.

推荐答案

您应该把jar包到lib目录(WebContent-WEB-INF-lib目录),然后右键点击jar包,构建路径,添加到构建路径

You should put the jar package into the lib folder(WebContent-WEB-INF-lib),and right click on the jar package-build path-add to build path

这篇关于抛出java.lang.ClassNotFoundException:org.postgresql.Driver,机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆