Domino connection to Oracle solution-JDBC

Source: Internet
Author: User

Original article address: Domino connection to Oracle solution-Author: zwm136200

Preface

This article only briefly introduces the basic methods for Domino to interact with Oracle, and does not design complex technologies. For more information about complex applications, see other articles. The connection pool is used in this article. This article does not specifically introduce the design scheme of the connection pool. In the next article, we will describe the specific design scheme of the connection pool! This article is only used for technical discussion, and you are welcome to correct the mistakes in this article.

Application background

Developing applications in Domino often requires access to data in some relational databases. In the past, in addition to using expensive lei, then there is ODBC (who has used other tools ?). But Domino is also evolving, just as society is constantly improving. After IBM launched domino6.0, everything seemed to be changing! IBM seems to be aware of the importance of Domino's data interaction with other systems. In domino6.0, DCR and DECs are added, and Lei is still following up. Although domino6.0's data integration function is even more powerful, one thing is to achieve interaction with other databases through configuration. The advantage of configuration is that it is okay to click a few mouse clicks and create several documents for an application. complex programming and tedious testing are not required. Defects are not flexible enough. Often these configuration tools cannot meet our needs, or these tools are defective, resulting in too much manual maintenance, such as DECS. Of course, we have different requirements. In my project, DECs and Lei cannot meet my requirements. DCR can only be associated with DB2, not what I need. Therefore, the methods described in this article may not be suitable for you. Okay. Continue.

Since these tools cannot be used by me, we can find other ways to achieve our goal. Fortunately, after domino6, the support for Java has been enhanced, and the number of functions that can be implemented has increased, and more methods have been selected for us.

I just wanted to have a question. In the past, when I was working on a project, I needed to access data from other databases. I could only use the ODBC driver on the Windows platform. The cost of doing so is that you can only deploy applications on the Windows platform, rather than using Unix-like systems. This is like being shackled. My requirement is to be cross-platform, so there is only one option-JDBC.

This is not surprising. In today's enterprise applications, only JDBC and ODBC cross-database connection technologies are available, only JDBC can be competent. So how can we make Domino use the JDBC driver. You can do the same with me one step by one. Start with the question below.

Ii. Actual operations

1. Prepare the development environment

Let's talk about the development environment:

Domino platform: domino6.5.5

Operating System: aix5.3

Database: Oracle 9.2.0.8

Development tools: Lotus designer + eclipse

You can also test the combination of domino6.5.5 + WINXP + MySQL on your machine.

Prepare the oracle JDBC driver classes12.jar, copy the jar package to the JVM/lib/EXT directory under the domino program directory, and then restart the Domino server. Now you can use the JDBC driver in your program. It's easy!

2. Create a domino design element

Now I start the actual operation. Create a database jdbctest. nsf, and then create a new form frmjdbctest

, Create several fields and two buttons in the form.

Is the style in IE browser.


3. Create a table in Oracle

. Create a jdbctest table, including the fld_name, fld_general, fld_birthdayyear, fld_birthdaymonth, and fld_birthdayday fields.

4. Write a program

Compile two proxies, agtdominotooracle (Appendix 1) and agtoracletodomino (appendix 2)

The "save data" button triggers the agent agtdominotooracle.

The "fetch data" button triggers the agent agtoracletodomino.

5. Run the program

Enter data in the form, and then click "save data.

Then, click the "fetch data" button to actually store data in Oracle.

This is the data obtained through PL/SQL, such

The input data in Domino has been stored in Oracle, but Domino does not store any data.


Click "data" to obtain the data in Oracle.

II.

Summary

Through the above steps, we can see that the interaction between Domino and Oracle and other databases is actually very simple. This is not an advanced technology, and the purpose of this article is also to inspire others. I hope everyone will contribute their own wisdom and let us work together to make the future of Domino better!

Attachment: Domino connecting to Oracle

××××××××××××××××××××××××××××××××××××××××××× * Agtdominotooracle. java × ××××××××××××××××××××××××××××××××××××× import Lotus. domino. *; import Java. SQL. *; import COM. sinosoft. dao. poolmanager; public class agtdominotooracle extends agentbase {public void notesmain () {session = NULL; agentcontext = NULL; document doccontext = NULL; stringbuffer strsql = NULL; string strname = NULL; string strgeneral = NULL; string strbir_year = NULL; string strbir_month = NULL; string strbir_day = NULL; connection conn = NULL; statement stmt = NULL; int iupdate = 0; try {session = getsession (); agentcontext = session. getagentcontext (); doccontext = agentcontext. getdocumentcontext (); // you may not understand the following procedure. This is the result of using the connection pool poolmanager PM = poolmanager. getinstanc E (); Conn = PM. getconnection ("Platform"); // The following section uses direct connection to access Oracle/* class. forname (strdbdriver); Conn = drivermanager. getconnection (strdburl, struser, strpasswd); */If (Conn! = NULL) {stmt = Conn. createstatement (resultset. type_scroll_insensitive, resultset. concur_read_only); // strname = doccontext. getitemvaluestring ("fld_name"); strgeneral = doccontext. getitemvaluestring ("fld_general"); strbir_year = doccontext. getitemvaluestring ("fld_birthdayyear"); strbir_month = doccontext. getitemvaluestring ("fld_birthdaymonth"); strbir_day = doccontext. getitemvaluestring ("fld_birthdayday "); Strsql = new stringbuffer (); strsql. append ("insert into jdbctest (fld_name, fld_general, fld_birthdayyear, fld_birthdaymonth, fld_birthdayday)"); strsql. append ("values ('" + strname + "',"); strsql. append ("'" + strgeneral + "',"); strsql. append ("'" + strbir_year + "',"); strsql. append ("'" + strbir_month + "',"); strsql. append ("'" + strbir_day + "')"); iupdate = stmt.exe cuteupdate (strsql. tostring () ;}} catc H (exception e) {e. printstacktrace ();} finally {try {If (doccontext! = NULL) {doccontext. Recycle ();} If (agentcontext! = NULL) {agentcontext. Recycle ();} If (session! = NULL) {session. Recycle ();} If (stmt! = NULL) {stmt. Close ();} If (Conn! = NULL) {Conn. close () ;}} catch (exception E) {}}}×××××××××××××××××××××××××××××××××××××××× ××××××××××××××××××××××××××××××××××××××××××× agtoracletodomino. java × ××××××××××××××××××××××××××××××××××××× import Lotus. domino. *; import Java. SQL. *; import COM. sinosoft. dao. poolmanager; public class agtoracletodomino extends agentbase {public void notesmain () {session = NULL; agentcont EXT agentcontext = NULL; document doccontext = NULL; string strsql = NULL; string strname = NULL; string strgeneral = NULL; string strbir_year = NULL; string strbir_month = NULL; string strbir_day = NULL; stringbuffer strhtml = NULL; connection conn = NULL; statement stmt = NULL; resultset rs = NULL; try {session = getsession (); agentcontext = session. getagentcontext (); doccontext = agentcontext. getdocumentcont EXT (); system. out. println ("Run"); // The following section of the program, you may not understand, this is to take the connection pool poolmanager PM = poolmanager. getinstance (); Conn = PM. getconnection ("Platform"); // The following section uses direct connection to access Oracle/* class. forname (strdbdriver); Conn = drivermanager. getconnection (strdburl, struser, strpasswd); */If (Conn! = NULL) {stmt = Conn. createstatement (resultset. type_scroll_insensitive, resultset. concur_read_only); strsql = "select * From jdbctest"; RS = stmt.exe cutequery (strsql); strhtml = new stringbuffer (); strhtml. append ("[<Table>"); strhtml. append ("<tr> <TD> name </TD>"); strhtml. append ("<TD> gender </TD>"); strhtml. append ("<TD> birthday </TD> </tr>"); While (RS. next () {strname = Rs. getstring ("fld_name"); strgeneral = Rs. getstring ("Signature _ General "); strbir_year = Rs. getstring ("fld_birthdayyear"); strbir_month = Rs. getstring ("fld_birthdaymonth"); strbir_day = Rs. getstring ("fld_birthdayday"); strhtml. append ("<tr> <TD>" + strname + "</TD>"); strhtml. append ("<TD>" + strgeneral + "</TD>"); strhtml. append ("<TD>" + strbir_year + "year" + strbir_month + "month" + strbir_day + "day" + "</TD>");} strhtml. append ("</table>]"); doccontext. replaceitemvalue ("disora Cledata ", strhtml. tostring (). Recycle () ;}} catch (exception e) {e. printstacktrace () ;} finally {try {If (doccontext! = NULL) {doccontext. Recycle ();} If (agentcontext! = NULL) {agentcontext. Recycle ();} If (session! = NULL) {session. Recycle ();} If (stmt! = NULL) {stmt. Close ();} If (Conn! = NULL) {conn. Close () ;}} catch (exception e ){}}}}

Related Article

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.