Home > database >  JAVA how to access the DBLINK
JAVA how to access the DBLINK

Time:09-22

Company self-built system is mysql, oracle data to obtain some data need access to customers, give me the allocated a user can access only two views;

But the use of JDBC connection has no;
 
Connection conn=null;
PreparedStatement PSMT=null;
ResultSet rs=null;
List list=new ArrayList (a);
Try {
//the load driver
Class.forname (driveClassName);
//create a connection
Conn=DriverManager. GetConnection (jdbcUrl mysqlUserName, mysqlPassWord);
//. GetConnection (jdbcUrl,
//mysqlUserName mysqlPassWord);
PSMT=conn. PrepareStatement (SQL);
//execute SQL
Rs=PSMT. ExecuteQuery ();
//iterate through the result set
While (rs), next ()) {
TiensSpuDomain spu=new TiensSpuDomain ();
If (obj instanceof TiensSpuDomain) {
//* * * * * * * * *
//* * * * * * * * *
List. The add (spu);
}
//object V_MANAFRAME
TiensStoreDomain store=new TiensStoreDomain ();
If (obj instanceof TiensStoreDomain) {
MFCNAME store. SetMFCNAME (rs. Get string (" "));
MFCODE store. SetMFCODE (rs. Get string (" "));
List. The add (store);
}
}
return list;
} the catch (Exception e) {
Logger. The error (" database connection exception ", e);
} the finally {
Try {
rs.close();
PSMT. Close ();
conn.close();
} the catch (SQLException e) {
Logger. The error (" abnormal data connection closed ", e);
}
}



Customer said he would use dblink mode connection;
Big brother sisters, how to connect, consult;
Internet postings to local need to install oracle database client, but there is no detailed steps,

CodePudding user response:

Visit dblink method, and method of access to the local basic same, the difference is that

Select * from t @ dblin_name
  • Related