[問題] Struts1.3+資料庫(MySql)

看板java作者 (想到再說)時間6年前 (2017/09/17 12:17), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
大家好,想請教一下,我參考了 "王者歸來 JAVA Web 整合開發", 在 Action 內 ,利用以下三行連結資料庫(MySQL) Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); DataSource ds = (DataSource)envCtx.lookup("jdbc/struts"); 出現以下錯誤: Message java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null' 已在 WEBINF/lib/web.xml內 <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/struts</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> 及在 tomcat(9.0.0)/conf/context.xml 內,新增 <Context> <Resource name="jdbc/struts" auth="Container" type="javax.sql.DataSource" maxActive="5" maxIdle="2" maxWait="60" username="帳號" password="密碼" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/struts"/> </Context> -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.217.163.93 ※ 文章網址: https://www.ptt.cc/bbs/java/M.1505621857.A.A19.html

09/23 23:07, , 1F
WEBINF/lib/web.xml ?應該是WEB-INF/web.xml
09/23 23:07, 1F
文章代碼(AID): #1PlVTXeP (java)