JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » JDBC/SQL討論區 » lwdba  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
作者 lwdba 是不是連上sqlite 資料庫,會發生問題?
arliang





發文: 30
積分: 0
於 2012-05-17 15:19 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
lwdba 是不是連上sqlite 資料庫,會發生問題?

環境如下
lwdba + sqlite +winXP + java
設定檔如下
1
2
3
4
5
6
7
8
lwdba.pool.default.type=sqlite
lwdba.pool.default.driverClassName=org.sqlite.JDBC
lwdba.pool.default.driverURL=jdbc:sqlite:d:\\DB\\SQLite\\test.db
lwdba.pool.default.maxConnectionCount=32
lwdba.pool.default.encoding=UTF-8
lwdba.pool.default.sqlFile=sql
lwdba.pool.default.userName=
lwdba.pool.default.password=


主程式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    //DBFacade(String poolName)
    try {
      DBFacade connect = new DBFacade("default");
      DBRow dr = new DBRow("Artists", "ArtistID");
      dr.setColumn("ArtistID", "1");
      System.out.println(dr.toQueryString());
                        //以上正常
                        //這一行就掛了
      QueryResult result = connect.sqlQuery(dr.toQueryString());
 
      ArrayList<HashMap> list = result.getRows();
      for (HashMap hm : list){
        Iterator it = hm.keySet().iterator();
        while (it.hasNext()){
          String key = (String)it.next();
          System.out.println(key + "=" + hm.get(key));
        }
      }
    }catch(Exception e){
      e.printStackTrace();
    }
 
  }
 


出現 Exception
invalid database address: jdbc:apache:commons:dbcp:default

我不死心下載lwdba Source code lwdba_src_0.8.0
發現端倪如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public class SQLExecutor
{  
  // DBCP objects
  private GenericObjectPool connectionPool;
  private ConnectionFactory connectionFactory;
  private PoolableConnectionFactory poolableConnectionFactory;
  protected PoolingDriver driver;
 
  SQLExecutor(String _poolName) throws ClassNotFoundException, SQLException
  {
                 ....................
      connectionPool = new GenericObjectPool(null);
      connectionFactory = new DriverManagerConnectionFactory(driverURL, props);
      poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);
      driver.registerPool(poolName, connectionPool);
    }
  }
        ......................
 
  public Connection getConnection() throws SQLException
  {
                // poolName = "default";
    return DriverManager.getConnection("jdbc:apache:commons:dbcp:"+poolName);
  }
 
}
 


PoolingDriver 註冊 default 這個 connectionPool 都還算是正常,至少沒有Error
但是
DriverManager.getConnection("jdbc:apache:commons:dbcp:"+"default");
就掛了

2012/05/17 14:59:01 - SQLQuery: select * from Artists where ArtistID = '1'
java.sql.SQLException: invalid database address: jdbc:apache:commons:dbcp:default
  at org.sqlite.JDBC.createConnection(JDBC.java:74)
  at org.sqlite.JDBC.connect(JDBC.java:64)
  at java.sql.DriverManager.getConnection(DriverManager.java:582)
  at java.sql.DriverManager.getConnection(DriverManager.java:207)
  at tw.qing.lwdba.SQLExecutor.getConnection(SQLExecutor.java:113)
  at tw.qing.lwdba.SQLExecutor.executeQuery(SQLExecutor.java:121)
  at tw.qing.lwdba.DBFacade.sqlQuery(DBFacade.java:43)
  at tw.qing.lwdba.DBFacade.sqlQuery(DBFacade.java:38)
  at test.main(test.java:21)

請問這個症頭該如何解決呢?


reply to postreply to post
作者 Re:lwdba 是不是連上sqlite 資料庫,會發生問題? [Re:arliang]
arliang





發文: 30
積分: 0
於 2012-05-17 15:48 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
好像找到問題了,
要更新 依存lib 版本

commons-collections-3.2.1.jar
commons-dbcp-1.4.jar
commons-pool-1.6.jar

目前運做正常。

Smile


reply to postreply to post
» JWorld@TW »  JDBC/SQL討論區 » lwdba

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8