A Java JDBC SQL Server Driver class and URL example

Here's a quick post to help anyone that needs a quick JDBC Driver and URL reference when using Microsoft SQL Server with Java and JDBC.

The basic SQL Server JDBC Driver and URL information you need is shown here:

SQL Server URL String:  

SQL Server JDBC Driver String:

A SQL Server JDBC Driver and URL connection example

It may also help to see this SQL Server JDBC information used in a very simple Java application. To that end, here's a simple Java JDBC SQL Server example that shows how to use the SQL Server JDBC Driver and URL to establish a Java database connection:

public class JdbcSQLServerDriverUrlExample
  public static void main(String[] args)
    Connection connection = null;
      // the sql server driver string
      // the sql server url
      String url = "jdbc:microsoft:sqlserver://HOST:1433;DatabaseName=DATABASE";
      // get the sql server database connection
      connection = DriverManager.getConnection(url,"THE_USER", "THE_PASSWORD");
      // now do whatever you want to do with the connection
      // ...
    catch (ClassNotFoundException e)
    catch (SQLException e)

I hope this simple SQL Server JDBC reference is helpful. There are also many other Java, JDBC, and SQL Server tutorials on this site. Just use our search form to find many other examples.

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.