java代理存取Oracle数据库

 

 

import lotus.domino.*;
import java.sql.*;
import java.util.*;
import java.lang.*;
import java.io.*;

public class JavaAgent extends AgentBase { 
public void NotesMain() {
Connection conn
=null;
try { 
Session session 
= getSession();
AgentContext agentContext 
= session.getAgentContext();
Database curdb 
= agentContext.getCurrentDatabase();
Database db
=null;
View view
=null
Document doc
=null;
System.out.println(
"AgentGetERPPerson Start"); 
db 
= session.getDatabase(curdb.getServer(),"数据库路径",false);
if(db==null){
System.out.println(
"没有找到数据库。");
return;

  
DriverManager.registerDriver(
new oracle.jdbc.driver.OracleDriver()); 
conn
=DriverManager.getConnection("jdbc:oracle:thin:@Oracle数据库ip:1521:yqzl","用户名","密码"); 
String sql 
= "select * from csluser aa  ";

Statement stmt 
= conn.createStatement(); 
ResultSet rs 
= stmt.executeQuery(sql); 
int j =0;

String vname 
= "";
String accounts
="";
String workdate 
= "";
String borndate 
= "";

System.out.println(
"Succeed!");
while(rs.next())

vname 
=rs.getString("LAST_NAME"); 
accounts 
= rs.getString("USER_NAME"); 
workdate 
= rs.getString("GZRQ"); 
borndate 
= rs.getString("CSRQ"); 

doc 
= db.createDocument();
doc.replaceItemValue(
"form","Formname");
doc.replaceItemValue(
"name",vname);
doc.replaceItemValue(
"accounts",accounts);
doc.replaceItemValue(
"workdate",workdate);     
doc.replaceItemValue(
"borndate",borndate); 
doc.save();

j
++;                    

conn.close();
System.out.println(
"AgentGetERPPerson End");
catch(Exception e) {
System.out.println(
"AgentGetERPPerson:Error:"+e.getMessage());
try{
conn.close();
}
catch(Exception eCon){}
}
}

}

 

 

posted on 2010-10-25 21:29  麦特  阅读(697)  评论(0编辑  收藏  举报