Skip to content

Instantly share code, notes, and snippets.

@ColbyLeclerc
Created August 27, 2018 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ColbyLeclerc/8df0e4d880a882720b1639ac2ae112cc to your computer and use it in GitHub Desktop.
Save ColbyLeclerc/8df0e4d880a882720b1639ac2ae112cc to your computer and use it in GitHub Desktop.
//See https://github.com/ColbyLeclerc/blog-connection-pools/blob/master/src/main/java/database/Connector.java
package database;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Connector {
public Connection getDMConnection() {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e) {
throw new RuntimeException("Cannot find the driver in the classpath!", e);
}
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:sqlserver://SERVERIP:PORT;databaseName=DATABASE", "USER", "PASS");
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment