admin 管理员组

文章数量: 1184232


2024年3月11日发(作者:matlab线上版)

Domino访问Mysql数据库

JAVA代理访问

使用Java代理库接Mysql,其与Java访问Mysql数据库大体上类似,使用JDBC进行

数据库连接,但有一点区别,就是Java代理有安全性等级的设置。所以,使用JAVA代理

访问Mysql时有以下几点需要注意:

1、 需要将与Mysql对应的连接驱动拷贝至domino服务器程序目录下的jvm/lib/ext下

(也可以将其拷贝至服务器的其它目录,并在里做对应的配置),并重启domino服

务器。

2、 需要修改该domino代理的安全性等级为2级或3级,如下图:

3、 如果该代理需要在Notes客户端上运行,需要将Mysql对应的驱动拷贝至Notes目

录下的jvm/lib/ext下。

数据库添加代码:

import .*;

import .*;

import ist;

import riter;

public class JavaAgent extends AgentBase {

String url = "jdbc:mysql://localhost:3306/mytask";

Connection conn=null;

Statement statement=null;

ResultSet rs=null;

//数据库连接

public boolean CONN(){

try{

e("");

conn = nection(url, "root", "mysql");

statement = Statement();

return true;

}catch(Exception e){return false;}

}

//查询

public ResultSet Select(String sql){

if(())

{

try{

rs = eQuery(sql);

}

catch(Exception e){}

return rs;

}

else return null;

}

//执行Sql语句

public boolean ExcuteSql(String sql){

boolean x=false;

if(())

{

try{

eUpdate(sql);

x=true;

}catch(Exception e){tackTrace();}

}

return x;

}

//数据库事务

public boolean ExcuteTrans(ArrayList al) {

boolean x=false;

if(()) {

try{

oCommit(false);

for(int i=0;i<();i++) {

String y = (i).toString();

e(y);

}

();

oCommit(true);

x=true;

}catch(Exception e){

try {

ck();

oCommit(true);

}catch(Exception ex){}

}

}

return x;

}

public void NotesMain() {

try {

Session s = getSession();

AgentContext ag = ntContext();

Database db = rentDatabase();

//Document doc = Document();

//ItemValue("Form", "showData");

Document doc = umentContext();

String sql;

sql = "insert into tasks(deptname,proname,taskname,excctype) values

('"+mValueString("DeptName")+"','"+mValueString("ProName")+"','"+

ItemValueString("TaskName")+"','"+mValueString("ExccType")+"')";

PrintWriter pw = getAgentOutput();

boolean result = Sql(sql);

if (result)

{

n("");

}

else n("");

} catch(Exception e) {

tackTrace();

}

}

}

数据库查询代码:

import .*;

import .*;

import ist;

public class JavaAgent extends AgentBase {

String url = "jdbc:mysql://localhost:3306/anatast";

Connection conn=null;

Statement statement=null;

ResultSet rs=null;

//数据库连接

public boolean CONN(){

try{

e("");

conn = nection(url, "root", "mysql");

statement = Statement();

return true;

}catch(Exception e){return false;}

}

//查询

public ResultSet Select(String sql){

if(())

{

try{

rs = eQuery(sql);

}

catch(Exception e){}

return rs;

}

else return null;

}

//执行Sql语句

public boolean ExcuteSql(String sql){

boolean x=false;

if(())

{

try{

eUpdate(sql);

x=true;

}catch(Exception e){tackTrace();}

}

return x;

}

//数据库事务

public boolean ExcuteTrans(ArrayList al) {

boolean x=false;

if(()) {

try{

oCommit(false);

for(int i=0;i<();i++) {

String y = (i).toString();

e(y);

}

();

oCommit(true);

x=true;

}catch(Exception e){

try {

ck();

oCommit(true);

}catch(Exception ex){}

}

}

return x;

}

public void NotesMain() {

try {

Session s = getSession();

AgentContext ag = ntContext();

Database db = rentDatabase();

//Document doc = Document();

//ItemValue("Form", "showData");

Document doc = umentContext();

ResultSet rs = ("select taskname,deptname,count(*) as num1 from tasks

group by taskname,deptname");

String result = "";

result = result + "

";

while(())

{

result = result + "

";

result = result

+"

";

result = result + "

";

}

}

}

result = result + "

流程环节部门3个月
"+ing("taskname")+""+ing("deptname")+""+i

ng("num1")+"

";

eItemValue("tData",result);

} catch(Exception e) {

tackTrace();

}


本文标签: 数据库 需要 代理 对应 拷贝