Code example for DataSource

Methods: getConnection

0
		ResultSet subtreeRS = null;
		 
		try 
		{ 
			//using some extra topology metadata to get the entire subtree in two queries instead of recursively querying for children 
			conn = pool.getConnection();
			String sql = "select * from topology where node_id = ?";
			getRoot = conn.prepareStatement(sql);
			getRoot.setInt(1, rootID);
			rootRS = getRoot.executeQuery();
			 
			if (rootRS.next()) {
				int maxDepth = rootRS.getInt("Depth") + depth;
				 
				sql = "select * " + 
					" from node natural join topology " +  
					" where LeftNode >= ? and RightNode <= ? and Depth <= ? and tree_id = ?" +  
					" order by Depth desc "; 
				 
				getSubtree = conn.prepareStatement(sql);
				getSubtree.setInt(1, rootRS.getInt("LeftNode"));