Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing a Table from another database 1

Status
Not open for further replies.

sumathy

MIS
Apr 10, 2002
1
IN
Hi!,<br>Is there a way to access a table from another database while working in another database?&nbsp;&nbsp;If so could anyone help me to do it?&nbsp;&nbsp;Its urgent!!!
 
I did it like this, hope it works 4 U..

Drop a agcData on your form, and set load data to (from business object)..
Businnes object name : your path to the bso
(I have this com.exemple.dsos.dsoEditTableData)
Now jou kan loop trhu the agcData to see what you get.
I hope this is what you r looking 4..

Code for de DataBussinesObject...
package com.examples.dsos;

import java.awt.*;
import java.util.*;
import java.math.*;
import com.sssw.srv.api.*;
import com.sssw.srv.mail.*;
import com.sssw.srv.busobj.*;
import java.io.*;
import com.sssw.rt.gui.*;
import com.sssw.rt.util.*;
import com.sssw.rt.event.*;
import java.awt.event.*;
import com.examples.dsos.JDBCDSO.*;

public class dsoEditTableData
implements AgiInitDatas,
AgiDataSourceListener
{


private Vector _ag_children = new Vector();
private Vector _ag_names = new Vector();
private String _ag_dbname = null;

public dsoEditTableData()
{
//==== Warning: SilverStream-generated method: do not edit. All changes will be lost ===

return;
}

public void ag_initDataStores(AgoBusinessObjectEvent e) throws Exception
{
//==== Warning: SilverStream-generated method: do not edit. All changes will be lost ===
return;
}

public void invokeQuery(AgoDataSourceEvent evt) throws Exception
{

String dbName = &quot;TelApp&quot;; // (String) htParms.get(&quot;DBNAME&quot;);
String tableName = &quot;PERSOON&quot;;// (String) htParms.get(&quot;TABLENAME&quot;);

//Hashtable htParms = (Hashtable) evt.getParameter();
//String semail = (String) htParms.get(&quot;SEMAIL&quot;);

AgiDatabase adb = evt.getServer().getDatabase(dbName);
if (adb==null)
throw new Exception (&quot;DATABASE: &quot; + dbName + &quot; was not available!&quot;);

java.sql.Connection conn = adb.getConnection (true);
java.sql.Statement stmt = conn.createStatement();

java.sql.ResultSet rs = stmt.executeQuery (&quot;select ACHTERNAAM,AANHEF_ID,VOORLETTERS,TUSSENVOEGSELS,ID,EMAIL from &quot; + tableName + &quot; order by ACHTERNAAM&quot;);
java.sql.ResultSetMetaData rsm = rs.getMetaData();

evt.setResultSet(rs);
evt.setResult(&quot;succes&quot;);

//rsm = null;
//rs.close();
//rs = null;
//stmt.close();
//stmt = null;
adb.releaseConnection (conn);

return;
}

public char getDataTypeCode (int TYPE) {
char retCode = ' ';
switch (TYPE) {
case java.sql.Types.BIGINT : retCode = DatatypeCodes.TYPE_INT; break;
case java.sql.Types.BINARY : retCode = DatatypeCodes.TYPE_BYTEARRAY; break;
case java.sql.Types.BIT : retCode = DatatypeCodes.TYPE_BOOLEAN; break;

case java.sql.Types.CHAR : retCode = DatatypeCodes.TYPE_STRING; break;
case java.sql.Types.DATE : retCode = DatatypeCodes.TYPE_DATE; break;
case java.sql.Types.DECIMAL : retCode = DatatypeCodes.TYPE_BIGDECIMAL; break;
case java.sql.Types.DOUBLE : retCode = DatatypeCodes.TYPE_DOUBLE; break;
case java.sql.Types.FLOAT : retCode = DatatypeCodes.TYPE_FLOAT; break;
case java.sql.Types.INTEGER : retCode = DatatypeCodes.TYPE_INT; break;
case java.sql.Types.LONGVARBINARY : retCode = DatatypeCodes.TYPE_BYTEARRAY; break;
case java.sql.Types.LONGVARCHAR : retCode = DatatypeCodes.TYPE_STRING; break;
case java.sql.Types.NULL : retCode = DatatypeCodes.TYPE_NONE; break;
case java.sql.Types.NUMERIC : retCode = DatatypeCodes.TYPE_NUMERIC; break;
case java.sql.Types.OTHER : retCode = DatatypeCodes.TYPE_OTHER; break;
case java.sql.Types.REAL : retCode = DatatypeCodes.TYPE_FLOAT; break;
case java.sql.Types.SMALLINT : retCode = DatatypeCodes.TYPE_INT; break;
case java.sql.Types.TIME : retCode = DatatypeCodes.TYPE_TIME; break;
case java.sql.Types.TIMESTAMP : retCode = DatatypeCodes.TYPE_TIMESTAMP; break;
case java.sql.Types.TINYINT : retCode = DatatypeCodes.TYPE_INT; break;
case java.sql.Types.VARBINARY : retCode = DatatypeCodes.TYPE_BYTEARRAY; break;
case java.sql.Types.VARCHAR : retCode = DatatypeCodes.TYPE_STRING; break;
}
return retCode;
}
}



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top