English 中文(简体)
OSGI & Children Commons-DBCP 职衔
原标题:OSGI & Apache Commons-DBCP Classloading Issue

我继承了一些使用奥帕奇混凝土连接池的代码。 该法典与Eclipse/Equinox OSGi版本3.4.3(R34x_v20081215)、Cos-dbcp 1.2.2和Sengres jdbc38.3.603 bundles from Springsource.org合作。

我希望实现现代化,或许这是我的第一个错误!

当我使用新版本的Felix或Equinox OSGI Cores,加上新的邮政地址gresql JDBC3或JDBC4 bundles,以及最新版本的公墓(1.4.1)时,我就遇到了一个分类问题。 我进行了无数次搜查,发现共同财产法典应当有一个固定的DBCP-214,但似乎仍然失败。

我曾试图将遗嘱放在共同财产上。 MF 进口包裹线,但也没有发挥作用。

我在一名积极分子上写了简单的测试,首先有一个基本类别:forName()和司机Manager.getConnection(),这是工作上的罚款,但当我在基本数据库中添加,并建立了与基本数据来源的联系时,我获得了“NotFoundception”。 见以下守则实例。

• 预先获得任何帮助,建议......

Sau!

// This one fails with an exception
public void dsTest() {
    BasicDataSource bds = new BasicDataSource();
    ClassLoader cl;

    try {
        logger.debug("ContextClassLoader: {}", 
        Thread.currentThread().getContextClassLoader().toString());
        cl = this.getClass().getClassLoader();
        logger.debug("ClassLoader: {}", cl); 

        if (bds.getDriverClassLoader() != null) {
            logger.debug(bds.getDriverClassLoader().toString());
        }
        // The failure is the same with and with the setDriverClassLoader() line
        bds.setDriverClassLoader(cl);
        bds.setDriverClassName("org.postgresql.Driver");
        bds.setUrl("jdbc:postgresql://127.0.0.1/dbname");
        bds.setUsername("user");
        bds.setPassword("pword");
        Class.forName("org.postgresql.Driver").newInstance();
        conn = bds.getConnection();
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery("SELECT COUNT(*) FROM table");
        conn.close();
        logger.debug("Closed DataSource Test");
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.debug("Exception: {} ", ex.getMessage());
    }
}

// This one works
public void managerTest() {
    ClassLoader cl;
    try {
        cl = this.getClass().getClassLoader();
        logger.debug("ClassLoader: {}", cl);
        Class.forName("org.postgresql.Driver").newInstance();
        String url = "jdbc:postgresql://127.0.0.1/dbname";
        conn = DriverManager.getConnection(url, "user", "pword");

        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery("SELECT COUNT(*) FROM table");
        conn.close();
        logger.debug("Closed Manger Test");
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.debug("Exception: {} ", ex.getMessage());
    }
}
问题回答

这是因为,由于冲积层载重机,公用汽车不能看上实际驾驶班。 解决办法是,在具有动态意义的进口品的公用商品类别中添加一个碎片。 您所需要的实际负责人如下:

Fragment-Host: org.apache.commons.dbcp DynamicImport-Package: *

之后,你提到的法典仍然有效。 这种希望太晚了。





相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签