星期四, 5月 31, 2012

[Java] Cannot create JDBC driver of class '' for connect URL 'null'

想要透過local的專案直接連mysql所遇到的
Cannot create JDBC driver of class '' for connect URL 'null'錯誤訊息的方法,
Google到的資訊實在太多做法了,把試成功的經驗記錄一下。

step1:在專案內的WEB-INF/加入context.xml檔

<xml version="1.0" encoding="UTF-8"?>
<Context >
<Resource
                name="jdbc/資料表連接名稱"
                auth="Container"
                type="javax.sql.DataSource"
        maxActive="100"
                maxIdle="30"
                maxWait="10000"
        username="root"
                password="密碼"
                driverClassName="com.mysql.jdbc.Driver"
        autoReconnect="true"
                removeAbandoned="true"
                removeAbandonedTimeout="300"
                logAbandoned="false"
        url="jdbc:mysql://遠端IP:3306/資料庫名稱"/>
        
Context>


Tip:DBCP已經設全域設定了,所以這個不用加
step2:在專案的web.xml加入

<resource-ref>
      <description>DB Connectiondescription>
      <res-ref-name>jdbc/資料表連接名稱res-ref-name>
      <res-type>javax.sql.DataSourceres-type>
resource-ref>

非常重要!!記得要重新開Tomcat!!

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails