您的位置:程序门 -> 企业开发 -> lotus



domino java代理连sqlserver


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


domino java代理连sqlserver[已结贴,结贴人:mouze]
发表于:2007-07-02 16:34:08 楼主
我用的是domino7.0,成功连上了数据库,但是发现如果2个页面不停的运行这个java代理,运行几十次后就会报错,然后服务器挡机,   搞得我郁闷无比..急求一个正确的解决方案.以下是我的连接测试代码:
import   lotus.domino.*;
import   java.sql.*;
import   java.io.*;

public   class   javaagent   extends   agentbase   {


public   void   notesmain()   {
printwriter   out=getagentoutput();  
connection   con=null;
try   {
 
session   session   =   getsession();
agentcontext   agentcontext   =   session.getagentcontext();

//printstream   ps=new   printstream(new   fileoutputstream(new   file( "c:\\log.txt ")));
                    //system.setout(ps);
system.out.println( "连接数据库正常 ");
//   (your   code   goes   here)  
class.forname( "com.microsoft.jdbc.sqlserver.sqlserverdriver ");
string   connquery= "jdbc:microsoft:sqlserver://10.1.27.27:1433;databasename=filebrowser ";
//string   url   =   "jdbc:odbc:driver={sqlserver};server=sqlserver;uid=sa;pwd=sa;database=filebrowser ";      
                              con=drivermanager.getconnection(connquery, "sa ", "sa ");    
                              system.out.println( "连接数据库正常 ");      
       
        thread.currentthread().sleep(800);
                              //然后创建一个jdbc声明          
    statement   stmt       =       con.createstatement();          
  //创建结果集      
  resultset   rs       =       stmt.EXECutequery( "select   *   from   userinfo ");      
  while(rs.next()){
  system.out.println(rs.getstring(2));
}

}  
catch(exception   e)   {
system.out.println( "here! ");
//system.out.println(e.getstacktrace());
e.printstacktrace();
}
finally{
try{
if(con!=null)   con.close();
}
catch(exception   e){system.out.println( "clean   up   has   problem! ");}
}
}
}
发表于:2007-07-02 17:02:591楼 得分:60
1、
加两句话

agentcontext.recycle();
agentcontext   =   null;
session.recycle();
session   =   null;

2、
ini文件中设置一个参数javamaxheapsize   ,   67108864对应64m
256m或者更大,你自己看着写

没问题就结贴吧,呵呵
发表于:2007-07-05 14:24:362楼 得分:40
补充:

别用jdbc做,用jdbc:odbc桥来做,基本上没有问题的,否则

javamaxheapsize   设置再大,也会宕机的,这种方法我做过很多项目了,一开始和你遇到的问题一样


快速检索

最新资讯
热门点击