Advertisement
Guest User

Connect

a guest
Sep 28th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. package connector;
  2. import java.sql.*;
  3.  
  4. public class Connect {
  5. public static Connection goConnect() {
  6. Connection con = null;
  7. try {
  8. DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
  9. } catch(Exception e) { System.out.println("Kan inte hitta databas drivrutin: " + e);}
  10.  
  11. try{
  12. con = DriverManager.getConnection ("jdbc:sqlserver://localhost:1433;"
  13. + "databaseName=Skola;user=sa;password=generation92;");
  14. //System.out.println("Ansluten");
  15. }catch (Exception e){
  16. System.out.println("Kan inte ansluta: " + e);
  17. }
  18.  
  19. return con;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement