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 {

     

        }

     }

    }

  • 相关阅读:
    读取手机联络人实例
    MotionEvent中getX()和getRawX()的区别
    Android开源项目发现--- 效率开发工具篇(持续更新)
    开发资源收藏
    ViewHolder VS HolderView ?
    如何测试 Android 中的定时事件
    性能优化实例
    lamba
    并行操作多个序列map
    连续处理函数reduce
  • 原文地址:https://www.cnblogs.com/tester2test/p/588501.html
Copyright © 2011-2022 走看看