WebSphere usage-Data Connection Pool

Source: Internet
Author: User
Tags websphere application server
IBM WebSphere Application Server (WebSphere Application Server) is a Web application server (containing ibm http server). It is essentially a web server plug-in suitable for servlets, provides enhanced servlet APIs and servlets management tools, and integrates JSP and database connection technologies. Because of project requirements, some Web applications need to be transplanted to WebSphere Application Server. As a project manager, I have made a preliminary exploration of this part of work over the past few days. I first downloaded the trial version of Websphere Application server6.0 from www.ibm.com. After Websphere is installed, open JBuilder X and find that JBuilder of this version does not support WebSphere Application server6.0. Therefore, jbuilder2006 is installed in a depressing manner. The development environment that can be confirmed is as follows: System Platform: Windows2000 Server Database: Oracle9i Application Server: WebSphere Application server6.0 for Windows programming environment: jbuilder2006, first, you must confirm that the database access is correct. Therefore, you need to set up a database connection pool on the installed WebSphere Application Server to ensure that Web applications can access the database. For specific JNDI settings, see the following web page http://www.matrix.org.cn/thread.shtml? Topicid = 30665 & forumid = 40. Note that a J2EE Connector Architecture (j2c) authentication must be set for the data source in version 6.0. After setting the user name and password for connecting to the data source, select the authentication alias you just set in the authentication alias of the data source Component Management. After completing the preceding configuration, you can test the connection pool. After the data connection pool test is successful, you need to consider how the web application can call the data connection pool for database connection. The data connection pool accessing the application server must be accessed through JNDI. The main program is as follows: Connection conn; statement stmt = NULL; datasource DS = NULL; resultset rs = NULL; try {ht. put (context. initial_context_factory, "com. IBM. webSphere. naming. wsninitialcontextfactory "); ht. put (context. provider_url, "IIOP: // 192.168.1.20.: 2809/"); Context CTX = new initialcontext (HT); object OBJ = CTX. lookup ("pubtest"); DS = (datasource) OBJ; Conn = Ds. getconnection (); stmt = Conn. createstatemen T (); RS = stmt.exe cutequery ("select * From Epub. sys_login_user "); While (RS. next () {out. println (RS. getstring ("user_code"); out. println (RS. getstring ("PWD"); out. println (RS. getdate ("up_date"); out. println (RS. getstring ("opr_code"); out. println (RS. getstring ("NOTE");} If (stmt! = NULL) {stmt. Close ();} If (Conn! = NULL) {If (! Conn. isclosed () {Conn. close () ;}} catch (exception ex) {// system. err. println ("database connection error:" + ex. getmessage (); out. print ("database connection error:" + ex. getmessage (); // output to the client ex. printstacktrace ();} after the program is compiled successfully, the following error occurs: javax. naming. namingexception: failed to initialize the orb [root exception is Java. lang. classcastexception: COM. sun. CORBA. se. impl. orb. orbimpl] at com. IBM. WS. naming. util. helpers. getorb (Helpe Rs. java: 294) at com. IBM. WS. naming. util. wsninitctxfactory. getinitialcontextinternal (wsninitctxfactory. java: 373) database connection setup error: failed to initialize the orb at com. IBM. WS. naming. util. wsninitctx. getcontext (wsninitctx. java: 112) at com. IBM. WS. naming. util. wsninitctx. getcontextifnull (wsninitctx. java: 422) at com. IBM. WS. naming. util. wsninitctx. lookup (wsninitctx. java: 143) at javax. naming. initialcontext. lookup (init Ialcontext. Java: 351) at testwebsphere. Test. Main (test. Java: 88 )............... After querying a large number of documents, we found that only JDK with IBM WebSphere 6.0 can be used to avoid the above errors. After JDK is changed, a new error occurs. lang. classcastexception: javax. naming. reference at com. IBM. RMI. javax. RMI. portableremoteobject. getobjectimpl (portableremoteobject. java: 614) at com. IBM. RMI. javax. RMI. portableremoteobject. narrow (portableremoteobject. java: 339) at javax. RMI. portableremoteobject. narrow (portableremoteobject. java: 157) database connection setup error: javax. naming. reference at testwebsphere. test. main (test. java: 89) This problem can be a headache, I have queried the network, but I have not found a solution. Finally, after two days of repeated tests and tests, the cause was found. The above code needs to be modified as follows. put (context. initial_context_factory, "com. IBM. webSphere. naming. wsninitialcontextfactory "); ht. put (context. provider_url, "IIOP: // 192.168.1.20.: 2809/"); Context CTX = new initialcontext (HT); Delete the preceding statement and add a statement context CTX = new initialcontext (); after the war file is generated by the project and published on websphere, it is successfully called through the web page. Conclusion: The Calling mechanism of Weblogic Web application data connection pool is different from that of Websphere. WebLogic can directly access the JNDI resources on the application server through the T3 protocol, webSphere needs to publish the Bean called by the resource to WebSphere by using the jar application, because it is local, so you do not need to set it. You only need to read the local initialcontext () then the corresponding JNDI interface can be lookup.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.