lotus与oracle数据库的连接问题

richardslinow 2004-05-06 05:02:47
怎样用lotus从oracle数据库中取数据,取出数据后怎样在网页上显示。请大虾们不吝赐教:) 谢谢!!!!!
...全文
53 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
richardslinow 2004-05-07
  • 打赏
  • 举报
回复
但是在代理中如果使用java的话,他会给出如下代码,我怎么把上面的代码嵌进去呢?

import lotus.domino.*;

public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();

// (Your code goes here)

} catch(Exception e) {
e.printStackTrace();
}
}
}
gjd111686 2004-05-06
  • 打赏
  • 举报
回复
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class JDBC_ODBC extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=gb2312\">");
out.println("<title></title>");
out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"/StyleLib/Default_Style_Sheet.css\">");
out.println("</head>");
out.println("<body>");
String driverName="sun.jdbc.odbc.JdbcOdbcDriver";
String connectionURL="jdbc:odbc:DSN_Oracle_System";
String strUserName="River";
String strPassword="River";
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
ResultSet rs_=null;

out.println("<select onchange=\"for(iIndex=0;iIndex<this.length;iIndex++){if(this.options[iIndex].selected){window.location='/servlet/JDBC_ODBC?TableName='+this.options[iIndex].text;}}\">");
String sqlStatement="select TName from tab";
try
{
Class.forName(driverName).newInstance();
con=DriverManager.getConnection(connectionURL,strUserName,strPassword);
stmt=con.createStatement();
rs=stmt.executeQuery(sqlStatement);
while(rs.next())
{
out.println("<option>");
out.println(rs.getString(1));
out.println("</option>");
}
}
catch(Exception ex)
{
}
finally
{
try
{
if(rs!=null)
{rs.close();}
if(stmt!=null)
{stmt.close();}
if(con!=null)
{con.close();}
}
catch(Exception ex)
{}
}
out.println("</select>");

String strTableName=req.getParameter("TableName");
if(strTableName!=null&&strTableName.length()>0)
{
sqlStatement="select * from "+strTableName;
}
else
{
strTableName="TAB";
sqlStatement="select * from "+strTableName;
}
out.println(strTableName);
out.println("<table border='0' cellspacing='1' cellpadding='0' bgcolor='#000000'>");
try
{
Class.forName(driverName).newInstance();
con=DriverManager.getConnection(connectionURL,strUserName,strPassword);
stmt=con.createStatement();
rs=stmt.executeQuery(sqlStatement);
ResultSetMetaData rsmd=rs.getMetaData();
int columnCount=rsmd.getColumnCount();
out.println("<tr bgcolor='#ffffff'>");
for(int iIndex=0;iIndex<columnCount;iIndex++)
{
out.println("<td width=20%>"+rsmd.getColumnLabel(iIndex+1)+"</td>");
}
out.println("</tr>");
int rowCount=0;
while(rs.next())
{
rowCount++;
out.println("<tr bgcolor='#ffffff'>");
for(int iIndex=0;iIndex<columnCount;iIndex++)
{
out.println("<td width=20%><input type='text' value='"+CNStr((String)rs.getString(iIndex+1))+"' style='border:1px none;width:100%;'></font></td>");
}
out.println("</tr>");
}
}
catch(Exception ex)
{
}
finally
{
try
{
if(rs!=null)
{rs.close();}
if(stmt!=null)
{stmt.close();}
if(con!=null)
{con.close();}
}
catch(Exception ex)
{}
}

out.println("</table>");

out.println("</body>");
out.println("</html>");
}
public String CNStr(String strValue)
{
try
{
String strBuffer=strValue;
byte[] byteBuffer=strBuffer.getBytes("ISO8859-1");
String strReturn=new String(byteBuffer,"gb2312");
return strReturn;
}
catch(Exception e)
{
return null;
}
}
}
gjd111686 2004-05-06
  • 打赏
  • 举报
回复
用LotusScript和Java都可以了.
LotusScript://注意系统数据源
Option Public
Uselsx "*lsxodbc"
Dim con As New ODBCConnection
If Not con.connectto(oracleDBName ,oracleUser,oraclePassword) Then
Exit Sub
End If
Dim qry As New ODBCQuery
Set qry.connection=con
Dim result As New ODBCResultSet
Set result.Query = qry
qry.sql= "select * from OracleTable"
result.Execute
result.Close()
con.Disconnect
Java:

535

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 Exchange Server
社区管理员
  • 消息协作社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧