package com.alcatel_lucent.nz.wnmsextract.database; /* * This file is part of wnmsextract. * * wnmsextract is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * wnmsextract is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import org.apache.log4j.Logger; /** * NPO48 was a non production test box with a DHCP IP. 48 may not necessarily match the IP address * specified in its definition. This is a JDC Connection implementation for that box * @author jnramsay * */ public class NPO48JDCConnector implements ALUJDCConnector{ private static Logger jlog = Logger.getLogger("com.alcatel_lucent.nz.wnmsextract.database.NPO48JDCConnector"); ALUConnectionDefinitions connectiondefinitions; private static final String DEF_USER = "pguser"; private static final String DEF_PASS = "pgpass"; private static final String DEF_HOST = "139.188.126.204"; private static final String DEF_PORT = "5432"; private static final String DEF_DBNM = "npo"; /* static { try{ new JDCConnectionDriver("org.postgresql.Driver","jdbc:postgresql","pguser","pgpass"); } catch(Exception e){ System.err.println("Error building JDCConnectionDriver :: "+e); } } */ public NPO48JDCConnector(ALUConnectionDefinitions cd){ setConnectionDefinitions(cd); init(); } public void init(){ jlog.info("Setup connection NPOJDC :: "+url()); try{ new JDCConnectionDriver(driver(),url(),DEF_USER, DEF_PASS); } catch(Exception e){ System.err.println("Error building JDCConnectionDriver :: "+e); } jlog.info("Connection complete, NPOJDC :: "+url()); } @Override public Connection getConnection() throws SQLException { return DriverManager.getConnection("jdbc:jdc:jdcpool"); } public ALUConnectionDefinitions getConnectionDefinitions() { return connectiondefinitions; } public void setConnectionDefinitions(ALUConnectionDefinitions cd) { this.connectiondefinitions = cd; } private String url(){ return connectiondefinitions.prefix()+"://"+DEF_HOST+":"+DEF_PORT+"/"+DEF_DBNM; } private String driver(){ return connectiondefinitions.driver(); } @Override public String toString(){ return "NPO:"+connectiondefinitions.driver(); } }