weblogic中连接池配置_Tomcat, WebLogic及J2EE讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  Tomcat, WebLogic及J2EE讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 1786 | 回复: 0   主题: weblogic中连接池配置        下一篇 
zhe.wan
注册用户
等级:上尉
经验:568
发帖:20
精华:0
注册:1970-1-1
状态:离线
发送短消息息给zhe.wan 加好友    发送短消息息给zhe.wan 发消息
发表于: IP:您无权察看 2015-7-3 9:24:07 | [全部帖] [楼主帖] 楼主

首先在myeclipse下建立一个项目(Test

北京联动北方科技有限公司

Entity:

      对象属性,添加get,set方法,不赘述。

Util包:

public class DBConection {
      private static Connection conn;
      public static Connection getConnection(){
            try {
                  Context ctx = new InitialContext();
                  DataSource ds = (DataSource) ctx.lookup("database");
                  conn = ds.getConnection();
            } catch (NamingException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            } catch (SQLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
            return conn;
      }
}


Dao包:

public class UserDao {
      private Connection conn = null;
      private PreparedStatement ps = null;
      private ResultSet rs = null;
      private User user = null;
      private ArrayList<User> userlist = null;
      public ArrayList<User> getAll(){
            conn = DBConection.getConnection();
            userlist = new ArrayList<User>();
            try {
                  ps = conn.prepareStatement("select * from userinfo");
                  rs = ps.executeQuery();
                  while(rs.next()){
                        user = new User();
                        user.setName(rs.getString(1));
                        user.setSex(rs.getString(2));
                        user.setAge(rs.getShort(3));
                        userlist.add(user);
                  }
            } catch (SQLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
            return userlist;
      }


简单jsp页面:

<body>
<%
User user = new User();
UserDao ud = new UserDao();
user = ud.getAll().get(1);
%>
<%=user.getName() %>
<%=user.getAge() %>
<%=user.getSex() %>
</body>


weblogic 控制台配置数据源:

北京联动北方科技有限公司

北京联动北方科技有限公司

北京联动北方科技有限公司

输入地址完成:

北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论