当前位置:首页
开发技术指南» 文章正文
    引言:

    摘要: 端口改成非默认之后,为什么isql工具就连不上数据库了. 达人指点! 谢谢! ......
    摘要: 如题,文件系统的方式是怎么运行的? ......


关于JSP调用WEBLOGIC连接池的问题

我在WEBLOGIC里面配置好ORACLE的连接池:  
  然后写了一个类DataSource,然后在其他页面调用出错  
   
   
  Compilation   of   d:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_newfx_newfx\jsp_servlet\_temp\__test.java   failed:  
  --------------------------------------------------------------------------------  
  d:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_newfx_newfx\jsp_servlet\_temp\__test.java:176:   cannot   access   scm.DatabaseConn  
  probably   occurred   due   to   an   error   in   /temp/test.jsp   line   6:  
  <jsp:useBean   id="DatabaseConn"   scope="page"   class="scm.DatabaseConn"/>  
   
   
  --------------------------------------------------------------------------------  
  Full   compiler   error(s):  
  d:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_newfx_newfx\jsp_servlet\_temp\__test.java:176:   cannot   access   scm.DatabaseConn  
  bad   class   file:   d:\bea\user_projects\domains\mydomain\myserver\.wlnotdelete\extract\myserver_newfx_newfx\jarfiles\_wl_cls_gen.jar(scm/DatabaseConn.class)  
  class   file   has   wrong   version   49.0,   should   be   48.0  
  Please   remove   or   make   sure   it   appears   in   the   correct   subdirectory   of   the   classpath.  
              scm.DatabaseConn   DatabaseConn   =   null;   //[   /temp/test.jsp;   Line:   6]  
                    ^  
  1   error  
   
   
   
   
  下面是类的源码:  
  package   scm;  
   
   
  import   java.sql.*;  
  import   javax.naming.*;  
  import   javax.sql.DataSource;  
  //一个用于查找数据源的工具类。  
  public   class   DatabaseConn   {  
  public     static     synchronized   Connection   getConnection()   throws   Exception  
  {  
  try  
  {  
   
  Context   initCtx   =   new   javax.naming.InitialContext();    
                          Context   envCtx   =   (Context)   initCtx.lookup("java:comp/env");    
                          DataSource   ds   =   (DataSource)initCtx.lookup("jdbc/bn");   ;  
  return   ds.getConnection();  
  }  
  catch(SQLException   e)  
  {  
  throw   e;  
  }  
  catch(NamingException   e)  
  {  
            throw   e;  
  }  
   
  }  
   
  }  
   
   
  调用页面的代码  
   
  <%@   page   contentType="text/html;   charset=gb2312"   %>  
  <%@   page   import="javax.naming.Context"   %>    
  <%@   page   import="javax.sql.DataSource"%>    
  <%@   page   import="javax.naming.InitialContext"%>    
  <%@   page   import="java.sql.*"%>    
  <jsp:useBean   id="DatabaseConn"   scope="page"   class="scm.DatabaseConn"/>  
  <%  
  //Connection   con=scm.getConn();  
          //Statement     stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);  
  Connection   con=DatabaseConn.getConnection();  
  Statement   stmt=con.createStatement();  
  String   sqlStr="select   *   from   body   order   by   lasttime   desc";  
  %>  
  ……………………………………………………  
 

NO.1   作者: dalishi1

import   javax.naming.*;  
  import   javax.sql.*;  
  import   java.sql.*;  
  import   java.util.*;  
   
  //import   oracle.sql.*;  
   
  public   class   DocMan{  
          Context   ctx=null;  
          DataSource   ds=null;  
        //   SysLog   log=null;  
          //ChangeEncoding   ce=null;  
  //构造函数  
          public   DocMan()  
          {  
              //从连接池中获取数据库连接  
              try{  
              ctx=new   InitialContext();  
              ds=(DataSource)ctx.lookup("myjndi");  
            }  
            catch(NamingException   e){  
            e.printStackTrace();  
          }  
          //log=new   SysLog();  
          //ce=new   ChangeEncoding();  
          }  
  //==================================

NO.2   作者: Tal

<jsp:useBean   id="DatabaseConn"   scope="page"   class="scm.DatabaseConn"/>


 ·哪有word的相关资料    »显示摘要«
    摘要: rt ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE