zoukankan      html  css  js  c++  java
  • Weblogic 连接池的建立程序应用

     

     连接池的建立

    public class mypooltest {

     public static void main(String[] args) {

        Statement stmt = null;

        Connection conn = null;

        ResultSet res = null;

        try {

          Hashtable env = new Hashtable();

     

          env.put(InitialContext.INITIAL_CONTEXT_FACTORY,

                  "weblogic.jndi.WLInitialContextFactory");

          env.put(InitialContext.PROVIDER_URL, "t3://localhost:7001");

          env.put(InitialContext.SECURITY_PRINCIPAL, "yuy");登录到weblgic的用名

          env.put(InitialContext.SECURITY_CREDENTIALS, "12345678");密码

          InitialContext ctx = new InitialContext(env);

          DataSource ds = (DataSource) ctx.lookup("mytest");JNDI名称为mytest

          conn = ds.getConnection();

          stmt = conn.createStatement();

          res = stmt.executeQuery("select * from man");

          System.out.println("id------name------address");

          while (res.next()) {

            int id = res.getInt(1);

            String name = res.getString(2);

            String address = res.getString(3);

     

            System.out.println(id + "------" + name + "------" + address);

          }

        }

        catch (SQLException sse) {

          System.out.println("sql error!");

        }

        finally {

     

        }

     }

    }

  • 相关阅读:
    99乘法表的几种实现方法
    log4net使用(包括单个文件和按日期生成多个文件)
    c# 压缩文件
    寻找Windows下MySQL的错误日志
    MySQL 索引
    java hashCode 作用
    springMVC swagger2
    ConcurrentHashMap原理分析(1.7与1.8)
    国产烂片深度揭秘
    Practice| 类型转换| 逻辑运算
  • 原文地址:https://www.cnblogs.com/tester2test/p/588501.html
Copyright © 2011-2022 走看看