// therefore, the jndi environment must be first set via a jndi.properties
// file, System properties, or by some other means.
InitialContext ctx = new InitialContext();
// acquire the DataSource... this is the only c3p0 specific code here
DataSource ds = (DataSource) ctx.lookup( jndiName );
// get hold of a Connection an do stuff, in the usual way
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
con = ds.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM foo");
while (rs.next())
System.out.println( rs.getString(1) );
}