Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Application freeze after some hours of no activity

    Hello!

    I'm new in JSP programming and have a problem for my first project
    I'm making deploy on the web server of my project which seems to work, on next day, after some hours of no activity, my application freeze, it doesn't open

    I suspect that problem can be with mysql connection, but I don't sure

    I'm using:
    Connector/J ver. 5.0 or 5.1 (with both of them have this problem)
    DBCP for connection pool

    In logs doesn't appear anything.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by erani View Post
    I suspect that problem can be with mysql connection, but I don't sure
    what is the basis of your suspicion? have you profiled your application to find out what might be causing the problem?
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sometimes I have this error:
    java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.

  • #4
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It seems that I solve problem adding:
    ds.setTestOnBorrow(true);
    ds.setValidationQuery("SELECT 1");
    to DataSource object

  • #5
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Problem is not solved

    Can somebody help?

  • #6
    Regular Coder Aradon's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    734
    Thanks
    0
    Thanked 20 Times in 19 Posts
    We will need to see your code in some fashion in order to figure out why this is happening. Otherwise we wont know what you're allocating to memory or what you aren't.
    "To iterate is human, to recurse divine." -L. Peter Deutsch

  • #7
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok!
    Here is my db connection class:
    Code:
    package cautare;
    
    import java.sql.*;
    import java.sql.Connection;
    import org.apache.commons.dbcp.BasicDataSource;
    
    
    public class DBbean2 {  
        private BasicDataSource ds = null;
        private static DBbean2 instance = null;
        private static final String connectURI= "jdbc:mysql://127.0.0.1:3306/nordik";
       
        public static synchronized DBbean2 getInstance()  {
            if (instance == null) {
                try {
                    instance = new DBbean2();
                } catch (ClassNotFoundException ex) {
                    ex.printStackTrace();
    			} catch (SQLException ex)  {
    				ex.printStackTrace();
    			}
            } 
            return instance;
        }
    
        protected DBbean2() throws ClassNotFoundException, SQLException  {
    		System.out.println("Run ver. 0.1");
    
    		ds = new BasicDataSource();
            ds.setDriverClassName("com.mysql.jdbc.Driver");
            ds.setUsername("user");
            ds.setPassword("pass");
            ds.setUrl(connectURI);
    		ds.setTestOnBorrow(true);
    		ds.setValidationQuery("SELECT 1");
            ds.addConnectionProperty("useUnicode", "true");
            ds.addConnectionProperty("characterEncoding", "UTF-8");
        }
        
       public Connection getConnection() throws SQLException, RuntimeException {
    	   Connection con = null;
    	   try {
    		 con = ds.getConnection();
    	   } catch (SQLException ex) {
    			throw new RuntimeException(ex);
    	   }
    
    	   return con;
       }
    
       public ResultSet executeQuery(String query, Statement stmt) throws SQLException{
             return stmt.executeQuery(query);
        }
    
        public int executeUpdate(String query, Statement stmt) throws SQLException{
            int n = stmt.executeUpdate(query);
            return n;
        }
    
        public void close(Connection con, Statement stmt, ResultSet rs) throws SQLException {
            if (rs != null) {
                rs.close();
            }
            if (stmt != null) {
                stmt.close();
            }
            if (con != null) {
                con.close();
            }
        }	
    }
    I can not give all the code, the project is big.
    Tell me, if you can, what can produce such problem, and I'll search.

    Also I was thinking about some thread deadlocks, but can not find in my code where it can happen


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •