title: Creating a Junit test that tests conection to SQL Server
body: <p>I am having a great deal of difficulty in either understanding what I am doing wrong or missing something fundamental. I have searched for my problem for a day or so and not understanding what I am missing.</p>
  
  <p>So what I am trying to do is Create a JUnit test that connects to my SQL server and does a query to get the current time. My connection to the server works and I have tested my SQL code in the Query on the server and works perfectly. For some reason the test isn't sending my code and getting anything returned.. Not sure what Ive done wrong an if this is too extensive for this form(little new to this)</p>
  
  <pre class="lang-java prettyprint-override"><code>@Override
      public Timestamp PCNow() throws PCSQLException {
  
          //SQL Server uses GETDATAE
          String strSQL = "SELECT GETDATE()";;
  
          try {
              //Get a result set with the timestamp field
              Timestamp datTs = (Timestamp)jdbcTemplate.queryForObject( strSQL, Timestamp.class );
  
              //Make sure there is a result
              if ( datTs == null )
                  //Throw an exception indicating the server could not give a time
                  throw new PCSQLException( "UNABLE_SERVER_TIME" );
  
              return datTs;
          }
          catch (Exception e) {
              throw new PCSQLException( "This didn't work PCNow", e );
          }
      }
  </code></pre>
  
  <p>This is my Test class</p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(locations = {"classpath:applicationContext-sql.xml"} )
  //instantiate TestExecutionListener class 
  @TestExecutionListeners
  
  public class ConnectionAdapterSQLTest {
  
    @Autowired
      ConnectionAdapterImpl connectionAdapterPC;
  
      private final Log log = LogFactory.getLog( getClass() );
  
      @Before
      public void setUp() throws Exception {
  
      }
  
      /**
       * @throws java.lang.Exception
       */
      @After
      public void tearDown() throws Exception {
      }
  
  
      @Test
      public final void testPCNow()  {
          log.info("testPCNow()");
  
          //fail("Not yet implemented");
      }
  </code></pre>
  
  <p>applicationContext-sql.xml </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;
  
      &lt;!-- connection to Sql Server using JDBC sqljdbc4.2 --&gt;
      &lt;bean id="dataSourcePC" class="org.apache.commons.dbcp.BasicDataSource"&gt;
          &lt;property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /&gt;
          &lt;property name="url" value="jdbc:sqlserver://******;databaseName=******" /&gt; 
          &lt;property name="username" value="******" /&gt;
          &lt;property name="password" value="******" /&gt; 
      &lt;/bean&gt;
  
      &lt;bean id="connectionAdapterPC"
          class="com.*******.*******.connections.ConnectionAdapterSQL"&gt;
          &lt;property name="dataSource" ref="dataSourcePC" /&gt;
          &lt;property name="useConnectionPool" value="false" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="dxDateTimeFormatter" class="com.*******.*******.data.format.DateTimeFormatter"&gt;
          &lt;property name="dateFormat" value="dd-MMM-yyyy" /&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>