|
|
package com.platform.service.impl;
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
import java.util.List;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.platform.dao.GatherOracleDao;
|
|
|
import com.platform.entities.GatherOracleInfo;
|
|
|
import com.platform.oracle.OracleConnector;
|
|
|
import com.platform.service.IMySqlService;
|
|
|
|
|
|
@Service(value = "mySqlService")
|
|
|
public class MySqlServiceImpl implements IMySqlService{
|
|
|
|
|
|
@Resource(name = "gatherOracleDao")
|
|
|
private GatherOracleDao gatherOracleDao;
|
|
|
|
|
|
@Override
|
|
|
public List<GatherOracleInfo> findAllMySql() throws Exception {
|
|
|
List<GatherOracleInfo> result = gatherOracleDao.selectAllOracle();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int deleteMySql(int id) throws Exception {
|
|
|
|
|
|
int result = 0;
|
|
|
if (id > 0) {
|
|
|
// result = gatherOracleDao.deleteOracleById(id);
|
|
|
GatherOracleInfo oracle = new GatherOracleInfo();
|
|
|
oracle.setId(id);
|
|
|
oracle.setRemove("1");
|
|
|
result = gatherOracleDao.updateOracleById(oracle );
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public int insertOracle(GatherOracleInfo oracle) throws Exception {
|
|
|
//TODO 连接oracle,
|
|
|
int result = gatherOracleDao.insertOracle(oracle);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int updateOracle(GatherOracleInfo oracle) throws Exception {
|
|
|
int status = 1;
|
|
|
Connection conn = null /*OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracle.getIp() + ":" + oracle.getPort() + ":"
|
|
|
+ oracle.getDatabaseName(), oracle.getUser(), oracle.getPassword())*/;
|
|
|
if (null == conn) {
|
|
|
status = 0;
|
|
|
}
|
|
|
oracle.setStatus(status);
|
|
|
int result;
|
|
|
if (oracle.getId() > 0) {
|
|
|
result = gatherOracleDao.updateOracleById(oracle);
|
|
|
}
|
|
|
else {
|
|
|
result = gatherOracleDao.insertOracle(oracle);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|