简体   繁体   English

使用Ecllipse的Weblogic连接池

[英]Weblogic Connection Pooling using Ecllipse

In tomcat am writing these code:



In TestServlet:  In servlet class written these code

    Context envcontext=new InitialContext();
        Context iniitContext=(Context)envcontext.lookup("java:/comp/env");
    DataSource  datasource=(DataSource)iniitContext.lookup("jdbc/Mysql");
    Connection connection=datasource.getConnection();
        Statement stmt=(Statement) connection.createStatement();

how to get the MySQL database jndi connection in weblogic using Ecllipse 如何使用Ecllipse在Weblogic中获取MySQL数据库jndi连接

Well weblogic and tomcat wont differ in the way you get a connection from the pool.. but at first you need to initialize a database pool in the weblogic server by going to the Administration Console: 好了,weblogic和tomcat从池中获得连接的方式不会有所不同..但是首先,您需要通过转到管理控制台来初始化weblogic服务器中的数据库池:

under your server name to the left select Services Then go to Data Sources and add a New Data source.. 在服务器名称下方的左侧,选择服务,然后转到数据源并添加新数据源。

Please note that if you're in production mode in weblogic then you must click on lock and edit in the upper left corner and when done you should click on release configuration in the same location.. but when under development you wont need to do that.. 请注意,如果您处于Weblogic的生产模式,则必须单击锁定并在左上角进行编辑,完成后应单击相同位置的发行版配置。.但是在开发中,则不需要这样做..

After adding a new MySQL data source just go to java and 添加新的MySQL数据源后,只需转到java和

Context initialContext = new InitialContext();
DataSource ds = (DataSource) initialContext.lookup("THE_MYSQL_JNDI_NAME_YOU_CHOSE");
Connection conn = ds.getConnection();

And that's it.. :-) 就是这样.. :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM