Guest User

Untitled

a guest
Jan 19th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'doszke'. ClientConnectionId:b7005fe3-904d-40c5-a89e-af0cb61250d6
  2. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:254)
  3. at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:258)
  4. at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:104)
  5. at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4772)
  6. at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3581)
  7. at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:81)
  8. at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3541)
  9. at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240)
  10. at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)
  11. at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2395)
  12. at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)
  13. at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)
  14. at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)
  15. at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)
  16. at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
  17. at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)
  18. at main.Main.main(Main.java:38)
  19.  
  20. package main;
  21.  
  22. import java.sql.*;
  23.  
  24. public class Main {
  25.  
  26.  
  27. private static ResultSet selectStan(Connection connection) throws SQLException {
  28. String sql_stmt = "SELECT * FROM STAN;";
  29. Statement statement = connection.createStatement();
  30. ResultSet result = statement.executeQuery(sql_stmt);
  31. System.out.println("Select executed");
  32. return result;
  33. }
  34.  
  35.  
  36. public static void main(String[] args) {
  37.  
  38.  
  39.  
  40. try {
  41. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  42. } catch (ClassNotFoundException e) {
  43. e.printStackTrace();
  44. }
  45.  
  46.  
  47. String userName = "doszke";
  48. String password = "doszke123";
  49.  
  50. String url = "jdbc:sqlserver://localhost:1433;databaseName=TestBazyDanych;user=doszke;password=doszke123";
  51.  
  52.  
  53. try (Connection con = DriverManager.getConnection(url)) {
  54.  
  55. if(con != null){
  56. System.out.println("connected");
  57. } else {
  58. System.out.println("unable to connect");
  59. }
  60.  
  61. }
  62. catch (SQLException e) {
  63. e.printStackTrace();
  64. }
  65.  
  66. }
  67.  
  68. }
Add Comment
Please, Sign In to add comment