3

I am trying to set a DataSource connection; the error I actually get is java.lang.AbstractMethodError: com.mysql.jdbc.Connection.isValid(I)Z

but the title's error pops up right above.

--

I have a caffeJdbc.java servlet with this DataSource setting

Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup("java:comp/env/jdbc/caffeDB");
Connection con = dataSource.getConnection();

--

This is the project web.xml setting, with servlet mapping and resource references

<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>

--

And this is the context.xml

<Context path="/JDBCDataSource">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <ResourceLink global="jdbc/caffeDB"
        name="jdbc/caffeDB"
        type="javax.sql.DataSource">
    </ResourceLink>
</Context>

I loaded both JDBC driver and the commons-dbcp2-2.1.1 one in the lib directory and in the path

pedro
  • 417
  • 2
  • 7
  • 25
  • 1
    May be JDBC driver is outdated. Look this, http://stackoverflow.com/questions/32783706/java-lang-abstractmethoderror-com-mysql-jdbc-connection-isvalidiz – parlad May 04 '17 at 14:44
  • I thought it was the last one released but, since you told me to, I checked and it was a 2007 one.. If you repost this as an answer I'll be happy to upvote it :) – pedro May 04 '17 at 14:59

1 Answers1

2

May be the JDBC Driver you are using is outdated, Please check that, You can see here for more info.

Community
  • 1
  • 1
parlad
  • 1,143
  • 4
  • 23
  • 42