| | |
| | | * Time: ?U?? 03:12:43 |
| | | * To change this template use File | Settings | File Templates. |
| | | */ |
| | | public class OracleTarget |
| | | { |
| | | public class OracleTarget { |
| | | private static final Logger logger = Logger.getLogger(OracleTarget.class); |
| | | private static OracleTarget _instance = null; |
| | | private static final String ORACLE_URL = "jdbc:oracle:thin:@"; |
| | | private static final String _propUsrKey = "user"; |
| | | private static final String _propPassKey = "password"; |
| | | private static String _oracleHost = "192.168.11.200"; |
| | | private static String _oracleInstance = "NNTPC"; |
| | | private static String _oracleHost = "10.10.1.7"; |
| | | private static String _oracleInstance = "ORCL"; |
| | | private static String _oraclePort = "1521"; |
| | | |
| | | static |
| | | { |
| | | try |
| | | { |
| | | static { |
| | | try { |
| | | DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | Assert.shouldNeverReachHere(e.getMessage()); |
| | | } |
| | | } |
| | |
| | | private OracleConnection oracleConnection = null; |
| | | private Properties properties; |
| | | |
| | | private OracleTarget() |
| | | { |
| | | private OracleTarget() { |
| | | properties = new Properties(); |
| | | properties.put(_propUsrKey, "SPATIALDB"); |
| | | properties.put(_propPassKey, "SPATIALDB000"); |
| | | properties.put(_propUsrKey, "system"); |
| | | properties.put(_propPassKey, "simple000"); |
| | | } |
| | | |
| | | public static String getOracleHost() |
| | | { |
| | | public static String getOracleHost() { |
| | | return _oracleHost; |
| | | } |
| | | |
| | | public static void setOracleHost(String oracleHost) |
| | | { |
| | | public static void setOracleHost(String oracleHost) { |
| | | OracleTarget._oracleHost = oracleHost; |
| | | } |
| | | |
| | | public static String getOracleInstance() |
| | | { |
| | | public static String getOracleInstance() { |
| | | return _oracleInstance; |
| | | } |
| | | |
| | | public static void setOracleInstance(String oracleInstance) |
| | | { |
| | | public static void setOracleInstance(String oracleInstance) { |
| | | OracleTarget._oracleInstance = oracleInstance; |
| | | } |
| | | |
| | | public static String getOraclePort() |
| | | { |
| | | public static String getOraclePort() { |
| | | return _oraclePort; |
| | | } |
| | | |
| | | public static void setOraclePort(String oraclePort) |
| | | { |
| | | public static void setOraclePort(String oraclePort) { |
| | | OracleTarget._oraclePort = oraclePort; |
| | | } |
| | | |
| | | public static String getCurrentURL() |
| | | { |
| | | public static String getCurrentURL() { |
| | | StringBuilder builder = new StringBuilder(); |
| | | |
| | | builder.append(ORACLE_URL); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | public String getLoginPass() |
| | | { |
| | | public String getLoginPass() { |
| | | return (String) properties.get(_propPassKey); |
| | | } |
| | | |
| | | public void setLoginPass(String loginPass) |
| | | { |
| | | public void setLoginPass(String loginPass) { |
| | | properties.put(_propPassKey, loginPass); |
| | | } |
| | | |
| | | public String getLoginUsr() |
| | | { |
| | | public String getLoginUsr() { |
| | | return (String) properties.get(_propUsrKey); |
| | | } |
| | | |
| | | public void setLoginUsr(String loginUsr) |
| | | { |
| | | public void setLoginUsr(String loginUsr) { |
| | | properties.put(_propUsrKey, loginUsr); |
| | | } |
| | | |
| | | public static OracleTarget getInstance() |
| | | { |
| | | if (_instance == null) |
| | | { |
| | | public static OracleTarget getInstance() { |
| | | if (_instance == null) { |
| | | _instance = new OracleTarget(); |
| | | } |
| | | |
| | | return _instance; |
| | | } |
| | | |
| | | public OracleConnection getOracleConnection() |
| | | { |
| | | try |
| | | { |
| | | if (oracleConnection == null) |
| | | { |
| | | public OracleConnection getOracleConnection() { |
| | | try { |
| | | if (oracleConnection == null) { |
| | | oracleConnection = (OracleConnection) DriverManager.getConnection(getCurrentURL(), properties); |
| | | } |
| | | |
| | | return oracleConnection; |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | public void closeConnection() |
| | | { |
| | | try |
| | | { |
| | | if (oracleConnection != null) |
| | | { |
| | | public void closeConnection() { |
| | | try { |
| | | if (oracleConnection != null) { |
| | | oracleConnection.close(); |
| | | oracleConnection = null; |
| | | } |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | } |