是一个网站,访问量一天也就几千左右,但是经常报奇怪的错误,有时侯报什么数据库连接次数据多,等等比如:
500 Servlet Exception
java.lang.NullPointerException
at _jsp._Index._index__jsp._jspService(Index/index.jsp:24)
at com.caucho.jsp.JavaPage.service(JavaPage.java:63)
at com.caucho.jsp.Page.pageservice(Page.java:569)
at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:159)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:208)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:259)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:341)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:467)
at com.caucho.util.ThreadPool.run(ThreadPool.java:408)
at java.lang.Thread.run(Thread.java:595)还有就是内存使用特别大,1G内存基本要用到800左右,很奇怪
我看了代码,觉得没问题,我也实在是找不出哪里的问题
我的配置平台是
操作系统:linux
中间服务器:resin
开发模式:jsp+javabean请高手指点指点,

解决方案 »

  1.   

    空指针的话是代码有错误。仔细检查。找到编译后的index_jsp.java看看第24行。不会找给我发消息。数据库连接用完一定要关闭
    Connection conn = null;
    PreparedStatement st = null;
    ResultSet rs = null;
    try{
      使用
    }finally{
      if(rs!=null)rs.close();
      if(st!=null)st.close();
      if(conn!=null)conn.close();
    }
    一天才几千用户算不上量。
      

  2.   

    对于连接,是用池。
    对于设计没有太大问题的系统,这是提升效率的很好的途径。还有对于一些非线程安全的类,或者方法,
    要加上synchronized关键字。
    保证其同步。
      

  3.   

    把index.jsp的24行左右的代码贴出来看看。
      

  4.   

    好哦,
    String sql="select * from infomation where bankid='368' and isCheck=1 order by id desc limit 1";
    rs=db.dbExecuteQuery(sql);
    if(rs.next()){
      

  5.   

    对,楼上说得对,我没有用到池,关于resin如何配置连接池,我配置了好多次都没成功,
      

  6.   

    public void dbConnection()throws Exception
    {
    try
    {
         Class.forName("com.mysql.jdbc.Driver");
         con=DriverManager.getConnection(dbUrl,dbUser,dbPwd);
         stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
    }
    catch(SQLException sqle)
    {
    System.out.println(sqle);
    }
    }
    连接mysal数据库
      

  7.   

    你的一些信息都是在那里得到的,可能在ACTION中你定义了变量。造成你的代码在访问多时造成,提取到另一个人的信息
      

  8.   

    应该贴编译以后的.java文件,而不是.jsp文件的第24行。
      

  9.   

    resin配置连接池,该如何配置,有没有高手知道
      

  10.   

    <resource-ref> 
    <res-ref-name>jdbc/blog</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <init-param driver-name="com.caucho.jdbc.mysql.Driver"/> 
    <init-param url="jdbc:mysql_caucho://localhost:3306/officedata"/> 
    <init-param user="root"/> 
    <init-param password=""/> 
    <init-param max-connections="20"/> 
    <init-param max-idle-time="30"/> 
    </resource-ref> 
    复制到resin.conf里面,启动resin报错
      

  11.   

    String newStr= new String(oldStr.getBytes("ISO8859_1"),"GB2312");
      

  12.   

    你这样是可以解决这个问题,但是我以前是在url里加入jdbc:mysql://localhost:3306/da?useUnicode=true&characterEncoding=gb2312
    的,我配置后连接池后,加上?后面那段resin就启动报错,如果去掉的话就全部是乱码,像楼上所讲可以解决但是,那我不是每个页的没个变量都要去加,改动好大呀,
    我现在是想在,连接池里的
            <database>
              <jndi-name>jdbc/da</jndi-name>
              <driver type="com.mysql.jdbc.Driver">
                <url>jdbc:mysql://localhost:3306/da?useUnicode=true&characterEncoding=gb2312</url>
                 <user>root</user>
                 <password></password>
                </driver>
                <prepared-statement-cache-size>8</prepared-statement-cache-size>
                <max-connections>20</max-connections>
                <max-idle-time>30s</max-idle-time>
             </database> 
    url里加上?后面的那段,去解决那个问题,就改动较小呀,如何在上面的url加启动rensin又不会报错呢?请大虾回答回答..