0

I have a little jsp site with a mysql DB (both hosted by a provider).

From time to time i get this error when i try to connection to the DB.

Communications link failure

The last packet successfully received from the server was 441,197
milliseconds ago.  The last packet sent successfully to the server was 26    
milliseconds ago.

I read several posts on the internet talking about similar problem, i but no one seems to suits my issue. Mine is a very simple site, maybe i should set some attributes in the context.xml file. I Created a context.xml similar to the one shown on the book i used to study java and jsp.

Here it is:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/prova" reloadable="true"> 
     <Resource
      name="jdbc/myDataSource"
      auth="Container"
      type="javax.sql.DataSource"
      url="..." 
      username="..."
      password="..."
      driverClassName="com.mysql.jdbc.Driver"/>  
</Context>

the way i "query" the DB is this:

1) i open the connection
2) i make the select
3) i close connection, statement and resultset

I use mysql-connector-java-5.1.17-bin.jar

MDP
  • 4,177
  • 21
  • 63
  • 119
  • 2
    Try to add folowing attributes to the Resource element: validationQuery="SELECT 1" testOnBorrow="true" – DmitryKanunnikoff Aug 19 '14 at 08:16
  • @matteodepasquali Try to increase mysql set timeout if this does not work then with the user your are trying to access does not have access to database tables. – pise Aug 19 '14 at 08:17
  • @Dmitry Tsechoev ill make it and ill make some tests. I'll make you know if the problem is solved – MDP Aug 19 '14 at 08:26
  • @pise i didnt unserstand the last part fo your answer. – MDP Aug 19 '14 at 08:26
  • @MatteoDepasquali I mean to say your database user may not be having access to that particular table, if so even that time you get this error. – pise Aug 19 '14 at 08:34
  • check out this [answer](http://stackoverflow.com/a/2985169/1066779) – Abhishek Nayak Aug 19 '14 at 09:36

0 Answers0