package test; import junit.framework.*; import java.sql.*; public class TestDBConnect extends TestCase { public void testDBConnection() throws java.sql.SQLException { ncsa.nvo.skynode.Configure config = new ncsa.nvo.skynode.Configure("/Configure.xml"); String dbDriver = config.getConfigParam("JDBCDriver")[0]; // Get the db parameters String jdbcUrl = config.getConfigParam("JDBCurl")[0]; String userName = config.getConfigParam("Username")[0]; String passWord = config.getConfigParam("Password")[0]; try { Class.forName(dbDriver); } catch (ClassNotFoundException e) { System.out.println( "JDBC Driver class not found: " + dbDriver + "\n" + "Check the JDBCDriver tag in Configure.xml" ); Assert.fail("JDBC Driver not found."); } try { Connection db = DriverManager.getConnection (jdbcUrl, userName, passWord); } catch (java.sql.SQLException e) { System.out.println( "Cannot connect to the database: " + jdbcUrl + "\n" + "Check the JDBCurl, Username and Password tags in Configure.xml" ); Assert.fail("Cannot connect to database."); } System.out.println( "Successful connection to database"); System.out.println( "JDBCDriver, JDBCurl, Username, Password Configured correctly"); } }