Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public void createConnection() throws ClassNotFoundException, SQLException {
  2. String hostName = "dsp.database.windows.net";
  3. String dbName = "University";
  4. String user = "dsp";
  5. String password = "Abc12345.";
  6. String url = String.format(
  7. "jdbc:sqlserver://%s:1433;database=%s;user=%s;password=%s;encrypt=true;hostNameInCertificate=*.database.windows.net;loginTimeout=30;",
  8. hostName, dbName, user, password);
  9. try {
  10. connection = DriverManager.getConnection(url);
  11. String schema = connection.getSchema();
  12. System.out.println("Successful connection - Schema: " + schema);
  13. } catch (Exception e) {
  14. e.printStackTrace();
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement