Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Cannot Load Mapped Connection Pool

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Location
    Michigan
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Cannot Load Mapped Connection Pool

    Hello, I am new here and this is my first post so if I mess up anything please let me know. I have taken an introductory course and an advanced course in Java but I am still a noob so I make noob mistakes. I should have a decent time understanding the jargon though.

    As for my problem... I have the following classes: DAO_LAPTOP_DB (which implements GenericDao) and DTO_LAPTOP_DB (which implements GenericDTO). I also have a main method... which is where I believe my issue lies. When I run my main method my XML file loads (this file holds all of my connection information -- username, password, driver, url, etc.) but I get the following errors in my console:

    CONSOLE ERROR
    Trying to load the XML file.
    XML file was loaded successfully.
    Data loaded: java.io.FileInputStream@32fb4f
    Failure to connect to the pool.
    java.sql.SQLException: No suitable driver found for fis
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at test.laptops.MainMethod2.main(MainMethod2.java:76)
    Exception in thread "main" java.lang.NumberFormatException: null
    	at java.lang.Integer.parseInt(Unknown Source)
    	at java.lang.Integer.parseInt(Unknown Source)
    	at test.laptops.MainMethod2.getChoice(MainMethod2.java:117)
    	at test.laptops.MainMethod2.main(MainMethod2.java:88)

    The mapped connection pool errors are the errors I need assistance with, I can figure out the NumberFormatException's on my own later. I just need a little bit of direction.. I have looked at multiple tutorials online but I can't seem to implement the examples into my code to make it work. My code is below:

    MAIN METHOD
    // Package
    package bambee.laptops;
     
    // Imported data
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.swing.JOptionPane;
     
    import edu.lcc.common.cpool.LCCConnectionPool;
    import edu.lcc.common.data.dao.DaoFactory;
     
    /**
    * @author bambee
    * @version 1.2.2
    * 
    */
    public class MainMethod2 {
     
    	// Constants
    	static Statement stmt;
    	static Connection con;
     
    	public static void main(String args[]){
     
    		FileInputStream fis = null;
     
    		// Use file input stream to connect to the properties XML file.
    		System.out.println("Trying to load the XML file.");
    		try {
    			fis = new FileInputStream("META-INF/test-config.xml");
    			System.out.println("XML file was loaded successfully.");
    			// FileInputStream error handling
    			} catch (FileNotFoundException e1) {
    				System.err.println("FileInputStream failed to " +
    						"load XML file. SQLException: " + e1.getMessage());
    				e1.printStackTrace();
    			}
     
    		// Set getFis() as the ConfigSource
    		try {
    			DaoFactory.setConfigSource(fis);
    		} catch (Exception e) {
    			System.out.println("Failure to successfully load the XML file as the configuration source.");
    			e.printStackTrace();
    		}
     
    		// Data loaded (shows print out)
    		try {
    			System.out.println("Data loaded: " + fis);
    		} catch (Exception e) {
    			System.out.println("Failure to print out the successfully loaded XML file to show that it is the configuration source.");
    			e.printStackTrace();
    		}
     
    		// New instance of driver
    		try {
    			Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    		} catch (InstantiationException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (IllegalAccessException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (ClassNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
     
    		// Connect to the pool
    		try {
    			@SuppressWarnings("unused")
    			LCCConnectionPool pool = (LCCConnectionPool) DriverManager.getConnection("fis");
    		} catch (SQLException e) {
    			System.out.println("Failure to connect to the pool.");
    			e.printStackTrace();
    		}
     
    		// Application Welcome Message
    		JOptionPane.showMessageDialog(null,"JAVADAL-33 App Dev User Acceptance");
    		int choice = -1;
     
    		// Get user selected choice
    		do {
    			choice = getChoice();
    			if (choice != 0){
    				// null pointer
    				getSelected(choice);
    				}
    			}
     
    		// If user selected '0' then exit application
    		while (choice !=  0);
    		System.exit(0);
     
    		}
     
    	/**
    	 * This method will return the user's menu choice
    	 * 
    	 * @return ch
    	 */
    	public static int getChoice()
    	{
    		String choice;
    		int ch;
    		choice = JOptionPane.showInputDialog(null,
    			"1. Insert data into LAPTOPS Table\n"+
    			"2. Retrieve data for LAPTOPS Table\n"+
    			"3. Update Laptops Table\n"+
    			"4. Delete Laptops Table (probably shouldn't)\n"+
    			"0. Exit\n\n"+
    			"Enter your choice");
    		ch = Integer.parseInt(choice);
    		return ch;
    	}
     
    	/**
    	 * This method determines which methods are called based on the user selection
    	 * 
    	 * @param choice
    	 */
    	public static void getSelected(int choice){
    		if(choice==1){
    			createLaptops();
    		}
    		if(choice==2){
    			readLaptops();
    		}
    		if(choice==3){
    			updateLaptops();
    		}
    		if(choice==4){
    			deleteLaptops();
    		}
    	}
     
    	/**
    	 * This method calls the create() method from DAO_LAPTOP_DB
    	 */
    	private static void createLaptops() {
     
    		DAO_LAPTOP_DB dao = (DAO_LAPTOP_DB) DaoFactory.getInstance(DAO_LAPTOP_DB.class).getDao();
    		DTO_LAPTOP_DB dto = new DTO_LAPTOP_DB();
     
    		dto.getId();
    		dto.getLid();
    		dto.getLccidnumber();
    		dto.getSub_type();
    		dto.getProcessor();
    		dto.getRam();
    		dto.getHarddrive();
    		dto.getModem();
    		dto.getTech();
    		dto.getPortreplicator();
    		dto.getGid();
    		dto.getDiscarded();
    		dto.getDiscard_approved_by();
    		dto.getDiscard_location();
    		dto.getDiscardedbrief();
    		dto.getDiscard_reason();
    		dto.getNotes();
    		dto.getCdfid();
    		dto.getLmid();
    		dto.getOs_id();
    		dto.getCid();
    		dto.getDelivery_date();
    		dto.getDiscarded_date();
    		dto.getPid();
    		dto.getLsnid();
    		dao.create(dto);
     
    		JOptionPane.showMessageDialog(null,"Data was inserted into the table successfully.");
    		}
     
    	/**
    	 * This method calls the readAll() method from DAO_LAPTOP_DB
    	 */
    	private static void readLaptops() {
     
    		DAO_LAPTOP_DB dao = (DAO_LAPTOP_DB) DaoFactory.getInstance(DAO_LAPTOP_DB.class).getDao();
    		DTO_LAPTOP_DB dto = new DTO_LAPTOP_DB();
     
    		dto.getId();
    		dto.getLid();
    		dto.getLccidnumber();
    		dto.getSub_type();
    		dto.getProcessor();
    		dto.getRam();
    		dto.getHarddrive();
    		dto.getModem();
    		dto.getTech();
    		dto.getPortreplicator();
    		dto.getGid();
    		dto.getDiscarded();
    		dto.getDiscard_approved_by();
    		dto.getDiscard_location();
    		dto.getDiscardedbrief();
    		dto.getDiscard_reason();
    		dto.getNotes();
    		dto.getCdfid();
    		dto.getLmid();
    		dto.getOs_id();
    		dto.getCid();
    		dto.getDelivery_date();
    		dto.getDiscarded_date();
    		dto.getPid();
    		dto.getLsnid();
    		dao.readAll(dto);
     
    		JOptionPane.showMessageDialog(null, "Data was successfully retrieved.");
    		}
     
    	/**
    	 * This method calls the update() method from DAO_LAPTOP_DB
    	 */
    	private static void updateLaptops() {
     
    		DAO_LAPTOP_DB dao = (DAO_LAPTOP_DB) DaoFactory.getInstance(DAO_LAPTOP_DB.class).getDao();
    		DTO_LAPTOP_DB dto = new DTO_LAPTOP_DB();
     
    		dto.getId();
    		dto.getLid();
    		dto.getLccidnumber();
    		dto.getSub_type();
    		dto.getProcessor();
    		dto.getRam();
    		dto.getHarddrive();
    		dto.getModem();
    		dto.getTech();
    		dto.getPortreplicator();
    		dto.getGid();
    		dto.getDiscarded();
    		dto.getDiscard_approved_by();
    		dto.getDiscard_location();
    		dto.getDiscardedbrief();
    		dto.getDiscard_reason();
    		dto.getNotes();
    		dto.getCdfid();
    		dto.getLmid();
    		dto.getOs_id();
    		dto.getCid();
    		dto.getDelivery_date();
    		dto.getDiscarded_date();
    		dto.getPid();
    		dto.getLsnid();
    		dao.update(dto);
     
    		JOptionPane.showMessageDialog(null, "Data was successfully updated.");
     
    	}
     
    	private static void deleteLaptops() {
     
    		DAO_LAPTOP_DB dao = (DAO_LAPTOP_DB) DaoFactory.getInstance(DAO_LAPTOP_DB.class).getDao();
    		DTO_LAPTOP_DB dto = new DTO_LAPTOP_DB();
     
    		dto.getId();
    		dto.getLid();
    		dto.getLccidnumber();
    		dto.getSub_type();
    		dto.getProcessor();
    		dto.getRam();
    		dto.getHarddrive();
    		dto.getModem();
    		dto.getTech();
    		dto.getPortreplicator();
    		dto.getGid();
    		dto.getDiscarded();
    		dto.getDiscard_approved_by();
    		dto.getDiscard_location();
    		dto.getDiscardedbrief();
    		dto.getDiscard_reason();
    		dto.getNotes();
    		dto.getCdfid();
    		dto.getLmid();
    		dto.getOs_id();
    		dto.getCid();
    		dto.getDelivery_date();
    		dto.getDiscarded_date();
    		dto.getPid();
    		dto.getLsnid();
    		dao.delete(dto);
     
    		JOptionPane.showMessageDialog(null, "Data was successfully deleted.");
    	}
     
    } // End main method

    DTO_LAPTOP_DB
    // Package
    package test.laptops;
     
    // Imported data
    import lccd.common.data.GenericDto;
     
    /**
    * This JAVA class should implement GenericDto, and it should also have one
    * field for each row in the table being used (in this class the table being
    * used is LAPTOPS). This model should be accessible throughout all layers 
    * (data/controller/view).
    *
    */
    public class DTO_LAPTOP_DB implements GenericDto {
     
    	/**
    	 * Current ID: {@value}
    	 */
    	private static final long serialVersionUID = 100000L;
     
    	// Properties
    	private int id;
    	private int lid;
    	private int cdfid;
    	private int lmid;
    	private int os_id;
    	private int cid;
    	private int portreplicator;
    	private int gid;
    	private int discarded;
    	private int pid;
    	private int lsnid;
    	private String lccidnumber = null;
    	private String sub_type = null;
    	private String processor = null;
    	private String ram = null;
    	private String harddrive = null;
    	private String modem = null;
    	private String tech = null;
    	private String discard_approved_by = null;
    	private String discard_location = null;
    	private String discardedbrief = null;
    	private String discard_reason = null;
    	private String notes = null;
    	private String delivery_date = null;
    	private String discarded_date = null;
     
     
    	public DTO_LAPTOP_DB () {
    	}
     
    	public int getId() {
    		return id;
    	}
     
    	public void setId(int id) {
    		this.id = id;
    	}
     
    	public int getLid() {
    		return lid;
    	}
     
    	public void setLid(int lid) {
    		this.lid = lid;
    	}
     
    	public int getCdfid() {
    		return cdfid;
    	}
     
    	public void setCdfid(int cdfid) {
    		this.cdfid = cdfid;
    	}
     
    	public int getLmid() {
    		return lmid;
    	}
     
    	public void setLmid(int lmid) {
    		this.lmid = lmid;
    	}
     
    	public int getOs_id() {
    		return os_id;
    	}
     
    	public void setOs_id(int os_id) {
    		this.os_id = os_id;
    	}
     
    	public int getCid() {
    		return cid;
    	}
     
    	public void setCid(int cid) {
    		this.cid = cid;
    	}
     
    	public int getPortreplicator() {
    		return portreplicator;
    	}
     
    	public void setPortreplicator(int portreplicator) {
    		this.portreplicator = portreplicator;
    	}
     
    	public int getGid() {
    		return gid;
    	}
     
    	public void setGid(int gid) {
    		this.gid = gid;
    	}
     
    	public int getDiscarded() {
    		return discarded;
    	}
     
    	public void setDiscarded(int discarded) {
    		this.discarded = discarded;
    	}
     
    	public int getPid() {
    		return pid;
    	}
     
    	public void setPid(int pid) {
    		this.pid = pid;
    	}
     
    	public int getLsnid() {
    		return lsnid;
    	}
     
    	public void setLsnid(int lsnid) {
    		this.lsnid = lsnid;
    	}
     
    	public String getLccidnumber() {
    		return lccidnumber;
    	}
     
    	public void setLccidnumber(String lccidnumber) {
    		this.lccidnumber = lccidnumber;
    	}
     
    	public String getSub_type() {
    		return sub_type;
    	}
     
    	public void setSub_type(String sub_type) {
    		this.sub_type = sub_type;
    	}
     
    	public String getProcessor() {
    		return processor;
    	}
     
    	public void setProcessor(String processor) {
    		this.processor = processor;
    	}
     
    	public String getRam() {
    		return ram;
    	}
     
    	public void setRam(String ram) {
    		this.ram = ram;
    	}
     
    	public String getHarddrive() {
    		return harddrive;
    	}
     
    	public void setHarddrive(String harddrive) {
    		this.harddrive = harddrive;
    	}
     
    	public String getModem() {
    		return modem;
    	}
     
    	public void setModem(String modem) {
    		this.modem = modem;
    	}
     
    	public String getTech() {
    		return tech;
    	}
     
    	public void setTech(String tech) {
    		this.tech = tech;
    	}
     
    	public String getDiscard_approved_by() {
    		return discard_approved_by;
    	}
     
    	public void setDiscard_approved_by(String discard_approved_by) {
    		this.discard_approved_by = discard_approved_by;
    	}
     
    	public String getDiscard_location() {
    		return discard_location;
    	}
     
    	public void setDiscard_location(String discard_location) {
    		this.discard_location = discard_location;
    	}
     
    	public String getDiscardedbrief() {
    		return discardedbrief;
    	}
     
    	public void setDiscardedbrief(String discardedbrief) {
    		this.discardedbrief = discardedbrief;
    	}
     
    	public String getDiscard_reason() {
    		return discard_reason;
    	}
     
    	public void setDiscard_reason(String discard_reason) {
    		this.discard_reason = discard_reason;
    	}
     
    	public String getNotes() {
    		return notes;
    	}
     
    	public void setNotes(String notes) {
    		this.notes = notes;
    	}
     
    	public String getDelivery_date() {
    		return delivery_date;
    	}
     
    	public void setDelivery_date(String delivery_date) {
    		this.delivery_date = delivery_date;
    	}
     
    	public String getDiscarded_date() {
    		return discarded_date;
    	}
     
    	public void setDiscarded_date(String discarded_date) {
    		this.discarded_date = discarded_date;
    	}
     
    }

    DAO_LAPTOP_DB
    // Package
    package test.laptops;
     
    //Imported data 
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
    import lccd.common.cpool.LCCConnectionPool;
    import lccd.common.data.dao.GenericDao;
    import lccd.common.util.DatabaseUtility;
     
    /**
     * The DAO is responsible for CRUD (create,read,update,delete) 
     * on the domain object
     */
    public class DAO_LAPTOP_DB implements GenericDao<DTO_LAPTOP_DB> {
     
    	// Properties
    	LCCConnectionPool conn=null;
    	PreparedStatement ptmt=null;
    	ResultSet rs=null;
     
    	/**
    	 * SQL Query to populate an LAPTOP object.
    	 * 
    	 * Value: {@value}
    	 */
    	private static final String LAPTOP_ID_QUERY = "" +
    	 "SELECT " +
    			"ID, " +
    	        "LID, " +
    			"CDFID, " +
    	        "LMID, " +
    			"OS_ID, " +
    	        "CID, " +
    			"PORTREPLICATOR, " +
    	        "GID, " +
    			"DISCARDED, " +
    	        "PID, " +
    			"LSNID, " +
    	        "LCCIDNUMBER, " +
    			"SUB_TYPE, " +
    	        "PROCESSOR, " +
    			"RAM, " +
    	        "HARDDRIVE, " +
    			"MODEM, " +
    	        "TECH, " +
    	        "DISCARD_APPROVED_BY, " +
    	        "DISCARD_LOCATION, " +
    	        "DISCARDEDBRIEF, " +
    	        "DISCARD_REASON, " +
    	        "NOTES, " +
    	        "DELIVERY_DATE, " +
    	        "DISCARDED_DATE " +
    	   	 "FROM JAVA_TEST_DATA_I ";
     
    	private LCCConnectionPool pool;
     
    	public DAO_LAPTOP_DB() {
    	}
     
    	@Override
    	public void setConnectionPool(LCCConnectionPool pool) {
    		this.pool = pool;
    	}
     
    	@Override
    	public boolean create(DTO_LAPTOP_DB dto) {
     
    		boolean success = false;
    		DTO_LAPTOP_DB tddto = (DTO_LAPTOP_DB)dto;
    		Object[] cols = new Object[4];
    		cols[0] = tddto.getId();
    		cols[1] = tddto.getLid();
    		cols[2] = tddto.getLccidnumber();
    		cols[3] = tddto.getSub_type();
    		cols[4] = tddto.getProcessor();
    		cols[5] = tddto.getRam();
    		cols[6] = tddto.getHarddrive();
    		cols[7] = tddto.getModem();
    		cols[8] = tddto.getTech();
    		cols[9] = tddto.getPortreplicator();
    		cols[10] = tddto.getGid();
    		cols[11] = tddto.getDiscarded();
    		cols[12] = tddto.getDiscard_approved_by();
    		cols[13] = tddto.getDiscard_location();
    		cols[14] = tddto.getDiscardedbrief();
    		cols[15] = tddto.getDiscard_reason();
    		cols[16] = tddto.getNotes();
    		cols[17] = tddto.getCdfid();
    		cols[18] = tddto.getLmid();
    		cols[19] = tddto.getOs_id();
    		cols[20] = tddto.getCid();
    		cols[21] = tddto.getDelivery_date();
    		cols[22] = tddto.getDiscarded_date();
    		cols[23] = tddto.getPid();
    		cols[24] = tddto.getLsnid();
     
    		success = DatabaseUtility.insert(LAPTOP_ID_QUERY, pool, cols);
     
    		return success;
    	}
     
    	@Override
    	public List<DTO_LAPTOP_DB> readAll(DTO_LAPTOP_DB combinedKey) {
     
    		String whereClause = "";
    		List<String> keycols = new ArrayList<String>();
    		List<Object> keyvals = new ArrayList<Object>();
    		DTO_LAPTOP_DB tdkey = (DTO_LAPTOP_DB)combinedKey;
     
    		if (tdkey.getId() != Integer.MIN_VALUE) {
    			keycols.add("ID");
    			keyvals.add(tdkey.getId());
    		}
    		if (tdkey.getLid() != Integer.MIN_VALUE) {
    			keycols.add("LID");
    			keyvals.add(tdkey.getLid());
    		}
    		if (tdkey.getLccidnumber() != null) {
    			keycols.add("LCCIDNUMBER");
    			keyvals.add(tdkey.getLccidnumber());
    		}
    		if (tdkey.getSub_type() != null) {
    			keycols.add("SUB_TYPE");
    			keyvals.add(tdkey.getSub_type());
    		}
    		if (tdkey.getProcessor() != null) {
    			keycols.add("PROCESSOR");
    			keyvals.add(tdkey.getProcessor());
    		}
    		if (tdkey.getRam() != null) {
    			keycols.add("RAM");
    			keyvals.add(tdkey.getRam());
    		}
    		if (tdkey.getHarddrive() != null) {
    			keycols.add("HARDDRIVE");
    			keyvals.add(tdkey.getHarddrive());
    		}
    		if (tdkey.getModem() != null) {
    			keycols.add("MODEM");
    			keyvals.add(tdkey.getModem());
    		}
    		if (tdkey.getTech() != null) {
    			keycols.add("TECH");
    			keyvals.add(tdkey.getTech());
    		}
    		if (tdkey.getPortreplicator() != Integer.MIN_VALUE) {
    			keycols.add("PORTREPLICATOR");
    			keyvals.add(tdkey.getPortreplicator());
    		}
    		if (tdkey.getGid() != Integer.MIN_VALUE) {
    			keycols.add("GID");
    			keyvals.add(tdkey.getGid());
    		}
    		if (tdkey.getDiscarded() != Integer.MIN_VALUE) {
    			keycols.add("DISCARDED");
    			keyvals.add(tdkey.getDiscarded());
    		}
    		if (tdkey.getDiscard_approved_by() != null) {
    			keycols.add("DISCARD_APPROVED_BY");
    			keyvals.add(tdkey.getDiscard_approved_by());
    		}
    		if (tdkey.getDiscard_location() != null) {
    			keycols.add("DISCARD_LOCATION");
    			keyvals.add(tdkey.getDiscard_location());
    		}
    		if (tdkey.getDiscardedbrief() != null) {
    			keycols.add("DISCARDEDBRIEF");
    			keyvals.add(tdkey.getDiscardedbrief());
    		}
    		if (tdkey.getDiscard_reason() != null) {
    			keycols.add("DISCARD_REASON");
    			keyvals.add(tdkey.getDiscard_reason());
    		}
    		if (tdkey.getNotes() != null) {
    			keycols.add("NOTES");
    			keyvals.add(tdkey.getNotes());
    		}
    		if (tdkey.getCdfid() != Integer.MIN_VALUE) {
    			keycols.add("CDFID");
    			keyvals.add(tdkey.getCdfid());
    		}
    		if (tdkey.getLmid() != Integer.MIN_VALUE) {
    			keycols.add("LMID");
    			keyvals.add(tdkey.getLmid());
    		}
    		if (tdkey.getOs_id() != Integer.MIN_VALUE) {
    			keycols.add("OS_ID");
    			keyvals.add(tdkey.getOs_id());
    		}
    		if (tdkey.getCid() != Integer.MIN_VALUE) {
    			keycols.add("CID");
    			keyvals.add(tdkey.getCid());
    		}
    		if (tdkey.getDelivery_date() != null) {
    			keycols.add("DELIVERY_DATE");
    			keyvals.add(tdkey.getDelivery_date());
    		}
    		if (tdkey.getDiscarded_date() != null) {
    			keycols.add("DISCARDED_DATE");
    			keyvals.add(tdkey.getDiscarded_date());
    		}
    		if (tdkey.getPid() != Integer.MIN_VALUE) {
    			keycols.add("PID");
    			keyvals.add(tdkey.getPid());
    		}
    		if (tdkey.getLsnid() != Integer.MIN_VALUE) {
    			keycols.add("LSNID");
    			keyvals.add(tdkey.getLsnid());
    		}
     
    		for (int i = 0; i < keycols.size(); i++) {
    			if (i == 0) {
    				whereClause += "WHERE ";
    			}
    			else {
    				whereClause += " AND ";
    			}
    			whereClause += keycols.get(i) + " = ?";
    		}
     
    		List<DTO_LAPTOP_DB> dtoList = new ArrayList<DTO_LAPTOP_DB>();
    		Object[][] rows = DatabaseUtility.selectAll(LAPTOP_ID_QUERY, pool, whereClause,
    				keyvals.toArray());
     
    		for(Object[] cols: rows) {
    			DTO_LAPTOP_DB tditem = new DTO_LAPTOP_DB();
     
    			tditem.setId((Integer)cols[0]);
    			tditem.setLid((Integer)cols[1]);
    			tditem.setLccidnumber((String)cols[2]);
    			tditem.setSub_type((String)cols[3]);
    			tditem.setProcessor((String)cols[4]);
    			tditem.setRam((String)cols[5]);
    			tditem.setHarddrive((String)cols[6]);
    			tditem.setModem((String)cols[7]);
    			tditem.setTech((String)cols[8]);
    			tditem.setPortreplicator((Integer)cols[9]);
    			tditem.setGid((Integer)cols[10]);
    			tditem.setDiscarded((Integer)cols[11]);
    			tditem.setDiscard_approved_by((String)cols[12]);
    			tditem.setDiscard_location((String)cols[13]);
    			tditem.setDiscardedbrief((String)cols[14]);
    			tditem.setDiscard_reason((String)cols[15]);
    			tditem.setNotes((String)cols[16]);
    			tditem.setCdfid((Integer)cols[17]);
    			tditem.setLmid((Integer)cols[18]);
    			tditem.setOs_id((Integer)cols[19]);
    			tditem.setCid((Integer)cols[20]);
    			tditem.setDelivery_date((String)cols[21]);
    			tditem.setDiscarded_date((String)cols[22]);
    			tditem.setPid((Integer)cols[23]);
    			tditem.setLsnid((Integer)cols[24]);
     
    			dtoList.add(tditem);
    		}
     
    		return dtoList;
    	}
     
    	@Override
    	public boolean update(DTO_LAPTOP_DB dto) {
    		boolean success = false;
    		List<String> cols = new ArrayList<String>();
    		List<Object> vals = new ArrayList<Object>();
    		DTO_LAPTOP_DB tddto = (DTO_LAPTOP_DB)dto;
     
    		if (tddto.getId() != Integer.MIN_VALUE) {
    			cols.add("ID");
    			vals.add(tddto.getId());
    		}
    		if (tddto.getLid() != Integer.MIN_VALUE) {
    			cols.add("LID");
    			vals.add(tddto.getLid());
    		}
    		if (tddto.getLccidnumber() != null) {
    			cols.add("LCCIDNUMBER");
    			vals.add(tddto.getLccidnumber());
    		}
    		if (tddto.getSub_type() != null) {
    			cols.add("SUB_TYPE");
    			vals.add(tddto.getSub_type());
    		}
    		if (tddto.getProcessor() != null) {
    			cols.add("PROCESSOR");
    			vals.add(tddto.getProcessor());
    		}
    		if (tddto.getRam() != null) {
    			cols.add("RAM");
    			vals.add(tddto.getRam());
    		}
     
    		if (tddto.getHarddrive() != null) {
    			cols.add("HARDDRIVE");
    			vals.add(tddto.getHarddrive());
    		}
    		if (tddto.getModem() != null) {
    			cols.add("MODEM");
    			vals.add(tddto.getModem());
    		}
    		if (tddto.getTech() != null) {
    			cols.add("TECH");
    			vals.add(tddto.getTech());
    		}
    		if (tddto.getPortreplicator() != Integer.MIN_VALUE) {
    			cols.add("PORTREPLICATOR");
    			vals.add(tddto.getRam());
    		}
    		if (tddto.getGid() != Integer.MIN_VALUE) {
    			cols.add("GID");
    			vals.add(tddto.getGid());
    		}
    		if (tddto.getDiscarded() != Integer.MIN_VALUE) {
    			cols.add("DISCARDED");
    			vals.add(tddto.getDiscarded());
    		}
    		if (tddto.getDiscard_approved_by() != null) {
    			cols.add("DISCARD_APPROVED_BY");
    			vals.add(tddto.getDiscard_approved_by());
    		}
    		if (tddto.getDiscard_location() != null) {
    			cols.add("DISCARD_LOCATION");
    			vals.add(tddto.getDiscard_location());
    		}
    		if (tddto.getDiscardedbrief() != null) {
    			cols.add("DISCARDEDBRIEF");
    			vals.add(tddto.getDiscardedbrief());
    		}
    		if (tddto.getDiscard_reason() != null) {
    			cols.add("DISCARD_REASON");
    			vals.add(tddto.getDiscard_reason());
    		}
    		if (tddto.getNotes() != null) {
    			cols.add("NOTES");
    			vals.add(tddto.getNotes());
    		}
    		if (tddto.getCdfid() != Integer.MIN_VALUE) {
    			cols.add("CDFID");
    			vals.add(tddto.getCdfid());
    		}
    		if (tddto.getLmid() != Integer.MIN_VALUE) {
    			cols.add("LMID");
    			vals.add(tddto.getLmid());
    		}
    		if (tddto.getOs_id() != Integer.MIN_VALUE) {
    			cols.add("OS_ID");
    			vals.add(tddto.getOs_id());
    		}
    		if (tddto.getCid() != Integer.MIN_VALUE) {
    			cols.add("CID");
    			vals.add(tddto.getCid());
    		}
    		if (tddto.getDelivery_date() != null) {
    			cols.add("DELIVERY_DATE");
    			vals.add(tddto.getDelivery_date());
    		}
    		if (tddto.getDiscarded_date() != null) {
    			cols.add("DISCARDED_DATE");
    			vals.add(tddto.getDiscarded_date());
    		}
    		if (tddto.getPid() != Integer.MIN_VALUE) {
    			cols.add("PID");
    			vals.add(tddto.getPid());
    		}
    		if (tddto.getLsnid() != Integer.MIN_VALUE) {
    			cols.add("LSNID");
    			vals.add(tddto.getLsnid());
    		}
     
    		success = DatabaseUtility.update(LAPTOP_ID_QUERY, pool,
    				cols.toArray(new String[cols.size()]), vals.toArray(),
    				cols.size() - 1);
     
    		return success;
    	}
     
    	/**
    	 * @return true
    	 */
    	public boolean canCreate() {	
    		return true;
    	}
     
    	/**
    	 * @return true
    	 */
    	@Override
    	public boolean canRead() {
    		return true;
    	}
     
    	/**
    	 * @return true
    	 */
    	@Override
    	public boolean canUpdate() {
    		return true;
    	}
     
    	/**
    	 * @return true
    	 */
    	@Override
    	public boolean canDelete() {
    		return true;
    	}
     
    	/**
    	 * @param key
    	 * @return dto_laptop
    	 */
    	@Override
    	public DTO_LAPTOP_DB read(Object key) {
    		// Read
    		DTO_LAPTOP_DB dto_laptop = null;
     
    		try {
    			Connection con = pool.getConnection();
     
    			try {
    				PreparedStatement stmt = 
    					con.prepareStatement(LAPTOP_ID_QUERY);
     
    				try {
    					stmt.setObject(1, ((String)key).toUpperCase());
    					ResultSet rs = stmt.executeQuery();
     
    					try {
    						if(rs.next()) {
    							dto_laptop = new DTO_LAPTOP_DB();
    							dto_laptop.setId(rs.getInt(1));
    							dto_laptop.setLid(rs.getInt(2));
    							dto_laptop.setCdfid(rs.getInt(3));
    							dto_laptop.setLmid(rs.getInt(4));
    							dto_laptop.setOs_id(rs.getInt(5));
    							dto_laptop.setCid(rs.getInt(6));
    							dto_laptop.setPortreplicator(rs.getInt(7));
    							dto_laptop.setGid(rs.getInt(8));
    							dto_laptop.setDiscarded(rs.getInt(9));
    							dto_laptop.setPid(rs.getInt(10));
    							dto_laptop.setLsnid(rs.getInt(11));
    							dto_laptop.setLccidnumber(rs.getString(12));
    							dto_laptop.setSub_type(rs.getString(13));
    							dto_laptop.setProcessor(rs.getString(14));
    							dto_laptop.setRam(rs.getString(15));
    							dto_laptop.setHarddrive(rs.getString(16));
    							dto_laptop.setModem(rs.getString(17));
    							dto_laptop.setTech(rs.getString(18));
    							dto_laptop.setDiscard_approved_by(rs.getString(19));
    							dto_laptop.setDiscard_location(rs.getString(20));
    							dto_laptop.setDiscardedbrief(rs.getString(21));
    							dto_laptop.setDiscard_reason(rs.getString(22));
    							dto_laptop.setNotes(rs.getString(23));
    							dto_laptop.setDelivery_date(rs.getString(24));
    							dto_laptop.setDiscarded_date(rs.getString(25));
    						}
    					} finally {
    						rs.close();
    					}
    				} finally {
    					stmt.close();
    				}
    			} finally {
    				con.close();
    			}
    		} catch (SQLException e) {
    			e.printStackTrace();
    		} catch (ClassNotFoundException e) {
    			e.printStackTrace();
    		}
     
    		return dto_laptop;
    	}
     
    	@Override
    	public boolean delete(Object key) {
    		// Delete --- "testcol_key" what is this??
    		boolean success = false;
    		success = DatabaseUtility.delete(LAPTOP_ID_QUERY, pool, "testcol_key", key);
    		return success;
    	}
     
    }

    Any direction is appreciated even if it is just re-directing me to a site I may have overlooked.

    I changed a few lines of code for privacy purposes. This code will not run in anyone else's IDE properly without the .JAR libraries I have installed. I do not feel comfortable uploading the specific .JAR files required because they were written by someone else. I hope that is all right.. I just need direction on where I should start next fixing my error, I do not need someone to completely re-write what I have done (and if you do I will not learn anything). This is my first time working with DTO, DAO, and pooling so bear with me pretty please



    UPDATED: I updated the main method code.
    Last edited by Noob_Ichigo; August 29th, 2012 at 01:15 PM.


  2. #2
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: Cannot Load Mapped Connection Pool

    For someone who has recently finished a live Java course, your naming conventions are very unusual. It's very difficult to read code that does not follow the expected conventions.

    Besides that, you should be careful using a static setup, because it makes it hard to change your class into something that can't be static, or would be extremely awkward if it was static. For example, what if you tried to switch to a graphical interface rather than a console setup?

    Another thing, you should avoid if at all possible initializing class-level variables in the same place that they are declared, as it is generally considered bad practice.

    Lastly, as to your problem, did you test the jdbc before making an entire application? A lack of basic testing can and will hurt you in the end, so first you should try an application that simply connects to the database. For a hint in your direction, you are attempting to open an oracle database connection to a FileInputStream, with a great lack of success.

  3. The Following User Says Thank You to Tjstretch For This Useful Post:

    Noob_Ichigo (August 30th, 2012)

  4. #3
    Junior Member
    Join Date
    Aug 2012
    Location
    Michigan
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Cannot Load Mapped Connection Pool

    I said I took both courses, I didn't say when I took them and this is the first time I have started coding an application since I have taken the class. I will be rusty, that's why I said I was a noob. Thank you for the link for the naming conventions, I had not realized that was an area I needed to improve (now I know, and I appreciate it). As for testing the JDBC I have not, but it was tested by another person before I was given the task to "connect" to a ApEx database.

    I also know what I am trying to accomplish, I am trying to use the FileInputStream to read an XML file with my data on it (username, pass,driver,etc) and with that information I am trying to connect to a database in ApEx. I will build a new small app just to test the connection and go from there, I think your suggestion of starting small will probably help me see where my errors are. I really appreciate your input, thank you

  5. #4
    Junior Member
    Join Date
    Aug 2012
    Location
    Michigan
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Cannot Load Mapped Connection Pool

    Thread is solved. Not sure how to set it to solved (at least I assume this type of forum would use a 'solved' button).

    So... I feel silly. The referenced libraries I have actually do everything I need it to do, I only needed to call: Connection con = pool.getConnection(); in my DAO class. I was registering drivers, and creating new connections in my main method which was making the whole process fail (since I was essentially duplicating the work... and putting it in the wrong place). So now all my methods just have that little line of code 'Connection con = pool.getConnection();' and everything works fine.

    PS - I fixed everything in my code to follow convention standards, and I asked a java guru about my static methods and they said what I had was fine for what I am doing so I think I am good to go.

    Thank you again!

  6. #5
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Cannot Load Mapped Connection Pool

    Quote Originally Posted by Noob_Ichigo View Post
    Thread is solved. Not sure how to set it to solved...
    In thread tools near the top of the page.





    Quote Originally Posted by Noob_Ichigo View Post
    ...(at least I assume this type of forum would use a 'solved' button)...
    I think if there was a more visible way to mark the threads SOLVED more people may do it. I spent some time looking for it on my first post.

Similar Threads

  1. oracle conection pool
    By arvindbis in forum JDBC & Databases
    Replies: 10
    Last Post: October 30th, 2011, 11:14 PM
  2. Connection pool and Datasource Implementation Is Not Functioning
    By mychickbad in forum What's Wrong With My Code?
    Replies: 0
    Last Post: July 14th, 2011, 06:15 PM
  3. Problem Configuring Connection Pool, DataSource, with MySQL, Tomcat 6
    By eboraks in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: July 11th, 2011, 10:50 AM
  4. Replies: 0
    Last Post: March 26th, 2011, 11:07 AM
  5. Replies: 0
    Last Post: January 12th, 2011, 08:41 AM