Advertisement
Guest User

Untitled

a guest
Sep 19th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. //package JDBCPackage;
  2. import java.sql.*;
  3. public class DAL {
  4. public static void main(String[ ] args) throws SQLException {
  5. try {
  6. // Ladda Oracle JDBC driver
  7. DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
  8. } catch(Exception e) { System.out.println("Kan inte database driver class: " + e);}
  9. try {
  10. //syntax : <host>:<port>:<sid>.
  11. Connection con =
  12. DriverManager.getConnection
  13. ("jdbc:sqlserver://localhost:1433;" + "databaseName=Skola;user=sa;password=generation92;");
  14. if (con == null)
  15. System.out.println("No driver found!");
  16. else
  17. System.out.println("Connection Established - SUCCESS!");
  18. } catch(Exception e) { System.out.println("Kaaaaaaaan inte hitta database driver class: " + e);}
  19.  
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement