Advertisement
fptf8fpt2018

Untitled

Jun 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1.  
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.SQLException;
  5. import java.util.logging.Level;
  6. import java.util.logging.Logger;
  7.  
  8. public class DBcontext {
  9.  
  10. private final String serverName = "localhost";
  11. private final String portNumber = "1433";
  12. private final String dbName = "Trading2019";
  13. private final String userId = "sa";
  14. private final String password = "123";
  15.  
  16. public Connection getConnection() throws SQLException, ClassNotFoundException {
  17. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  18. return DriverManager.getConnection(
  19. "jdbc:sqlserver://" + serverName + ":" + portNumber
  20. + ";databaseName=" + dbName,
  21. userId,
  22. password);
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement