Connecting to a SQLServer Database using the NetDirect JDBC driver : SqlServer « Database SQL JDBC « Java






Connecting to a SQLServer Database using the NetDirect JDBC driver

  

import java.sql.Connection;
import java.sql.DriverManager;

public class Main {
  public static void main(String[] argv) throws Exception {
    
    String driverName = "com.jnetdirect.jsql.JSQLDriver"; 
    Class.forName(driverName);
    
    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase; 
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);
  }
}

   
    
  








Related examples in the same category

1.Load driver for SQL Server
2.Connect to a database and read from table
3.Creating a SQLServer Table to Store Java Types