Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: DB Links, don't forget java
Don't forget you still can use java and don't use database links, in some
special situations.
Usually this is not too usefull, but when you want to avoid creating
database links, or in very exceptional situatoins.
One example (code from my friend Jery)
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "TestConnBD" AS import java.sql.Connection ;
import java.sql.DriverManager ; import java.sql.ResultSet ; import java.sql.Statement ;
{
String cRetorno = "F"; try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { System.err.println (e) ; cRetorno = "F"; return cRetorno;getString ("DSI_FECHA_SIS")) ;
}
try { // open connection to database Connection connection = DriverManager.getConnection( "jdbc:oracle:thin:@192.168.1.5:1521:"+ cBaseDatos, cUsuario, // ## fill in User here cPassword // ## fill in Password here ); // build query String query = "SELECT DSI_FECHA_SIS From DS_INIC" ; // execute query Statement statement = connection.createStatement () ; ResultSet rs = statement.executeQuery (query) ; System.out.println ("Test:") ; while ( rs.next () ) System.out.println ("FECHA DEL SISTEMA SOAB: " + rs
connection.close () ; cRetorno = "T"; return cRetorno;
}
catch (java.sql.SQLException e) { System.err.println (e) ; cRetorno = "F"; return cRetorno;
}
CREATE OR REPLACE
function daz.jav_consultabd(cBD in varchar2, cUser in varchar2, cPass in
varchar2) return VARCHAR2
as
language java name 'TestConnBD.Consulta( java.lang.String,java.lang
String,java.lang.String) return String';
/
test select daz.jav_ConsultaBD('SOAB','SOA','SOA') FROM DUAL
-- http://www.freelists.org/webpage/oracle-lReceived on Thu Sep 23 2004 - 14:41:40 CDT
![]() |
![]() |