JiveJdon3.0 配置檔案問題

bolaila發表於2005-02-15
各位好:
我是剛開始Jive 的學習,下面有一個問題我不理解其意圖是什麼,請各位不惜指教:
下面是jive_config.xml 的配置片段
<connectionProvider>
<className>com.jivesoftware.forum.database.DefaultConnectionProvider</className>
</connectionProvider>
<locale>
<country/>
<language>zh</language>
</locale>
<database>
<defaultProvider>
<driver>org.gjt.mm.mysql.Driver</driver>
<serverURL>jdbc:mysql://localhost:3306/Jive?useUnicode=true&characterEncoding=UTF-8</serverURL>
<username>my</username>
<password>my</password>
<minConnections>5</minConnections>
<maxConnections>50</maxConnections>
<connectionTimeout>0.5</connectionTimeout>
</defaultProvider>
</database>
<setup>true</setup>
</jive>
下面是呼叫的程式碼片段:
ConnectionManager.java
...
public static Connection getConnection() throws SQLException {
if (connectionProvider == null) {
synchronized (providerLock) {
if (connectionProvider == null) {
// Attempt to load the connection provider classname as
// a Jive property.
String className =
JiveGlobals.getJiveProperty("connectionProvider.className");
if (className != null) {
// Attempt to load the class.
try {
Class conClass = Class.forName(className);
setConnectionProvider((ConnectionProvider)conClass.newInstance());
}
catch(Exception e) {
e.printStackTrace();
System.err.println("Warning: failed to create the " +
"connection provider specified by connection" +
"Provider.className. Using the default pool.");
setConnectionProvider(new DefaultConnectionProvider());
}
}
else {
setConnectionProvider(new DefaultConnectionProvider());
}
}
}
}
Connection con = connectionProvider.getConnection();
if (con == null) {
System.err.println("WARNING: ConnectionManager.getConnection() " +
"failed to obtain a connection.");
}
// See if profiling is enabled. If yes, wrap the connection with a
// profiled connection.
//if (profilingEnabled) {
//return new ProfiledConnection(con);
//}
//else {
return con;
//}
}
從我在後臺輸出來看,知道是資料庫連線失敗!所以才會出現空指標的問題,資料庫連線是由ConnectionManager 這個類呼叫XMLProperties.java 中的getJiveProperty("connectionProvider.className");方法來得到一個Connection 的。
而這個<className>com.jivesoftware.forum.database.DefaultConnectionProvider</className>
的節點內容並沒有相關的連線設定,而是在別的地方設定的。
請問:
com.jivesoftware.forum.database.DefaultConnectionProvider
這句如何解釋?
謝謝!

相關文章