Advertisement
Guest User

Untitled

a guest
Jun 8th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. package fanese.web.model;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class Database {
  8.  
  9. private static final String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
  10. private static final String JDBC_URL = "jdbc:sqlserver://localhost;user=sa;password=123456;databaseName=UN3";
  11.  
  12. public static Connection getConnection() throws SQLException {
  13. try {
  14. Class.forName(DRIVER);
  15. } catch (ClassNotFoundException e) {
  16. throw new IllegalStateException(e);
  17. }
  18.  
  19. return DriverManager.getConnection(JDBC_URL);
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement