2
我試圖設置一個數據源連接;其實我得到的錯誤是java.lang.AbstractMethodError: com.mysql.jdbc.Connection.isValid(I)Z
Servlet.service()進行的servlet [...]與路徑上下文[/ ...]拋出異常[Servlet的執行引發異常]與根源
但標題的錯誤右上方彈出。
-
我有這個數據源設置caffeJdbc.java的servlet
Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup("java:comp/env/jdbc/caffeDB");
Connection con = dataSource.getConnection();
-
這是該項目的web.xml設置,與servlet映射和資源引用
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>tjdbc</servlet-name>
<servlet-class>caffeJdbc</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tjdbc</servlet-name>
<url-pattern>/caffeJdbc</url-pattern>
</servlet-mapping>
<resource-ref>
<res-ref-name>jdbc/caffeDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
-
server.xml中
<GlobalNamingResources>
<Resource name="jdbc/caffeDB"
global="jdbc/caffeDB"
url="jdbc:mysql://localhost:3306/caffe"/>
</GlobalNamingResources>
-
這是context.xml中
<Context path="/JDBCDataSource">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<ResourceLink global="jdbc/caffeDB"
name="jdbc/caffeDB"
type="javax.sql.DataSource">
</ResourceLink>
</Context>
我裝兩個JDBC驅動程序和公地dbcp2-2.1.1一個在lib目錄和路徑
可能JDBC驅動程序已過時。看看這個,http://stackoverflow.com/questions/32783706/java-lang-abstractmethoderror-com-mysql-jdbc-connection-isvalidiz –
我認爲這是最後一個發佈,但是,既然你告訴我,我檢查,這是一個2007年.. 如果你轉發這是一個答案,我會很樂意upvote :) – pedro