Created
August 27, 2018 16:32
-
-
Save ColbyLeclerc/8df0e4d880a882720b1639ac2ae112cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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