title: Connect Microsoft SQL with Java?
body: <p>I'm working on my project where I have to connect Microsoft SQL with Java. I want to pull information from my database. I keep getting this error:</p>
  
  <pre><code> SEVERE: Java Runtime Environment (JRE) version 1.8 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
  java.lang.UnsupportedOperationException: Java Runtime Environment (JRE) version 1.8 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.&lt;init&gt;(SQLServerConnection.java:304)
      at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1011)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at SendEmails.main(SendEmails.java:22)
  </code></pre>
  
  <p>Something is wrong with my Driver. I can not figure it out what. Maybe I have wrong path or something else. Here is my code:</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.Statement;
  
  public class SendEmails {
  
      public static void main(String[] args) {
  
          Connection conn = null;
          String dbName = "Student";
          String serverip="109.45.100.100";
          String serverport="1433";
          String url = "jdbc:sqlserver://"+serverip+"\\SQLEXPRESS:"+serverport+";databaseName="+dbName+"";
          Statement stmt = null;
          ResultSet result = null;
          String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
          String databaseUserName = "student";
          String databasePassword = "admin";
          try {
              Class.forName(driver).newInstance();
              conn = DriverManager.getConnection(url, databaseUserName, databasePassword);
              stmt = conn.createStatement();
              result = null;
              String pa,us;
              result = stmt.executeQuery("Select Top 45 * From Students ");
  
              while (result.next()) {
                  us=result.getString("uname");
                  pa = result.getString("pass");              
                  System.out.println(us+"  "+pa);
              }
  
              conn.close();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>If anyone knows what is wrong with my code please let me know.</p>