public class ConnectionDAO { protected Connection conn = null; protected PreparedStatement stmt = null; protected ResultSet result = null; public ConnectionDAO() { try { Configuration config = new Configuration(); Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); this.conn = DriverManager.getConnection("jdbc:sqlserver://" + config.getUrl() + ":1443;databaseName=" + config.getDatabase(), config.getUsername(), config.getPassword()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } } public class LoginDAO extends ConnectionDAO { public LoginDAO() { super(); } public UserBEAN getLogin(String username, String password) { UserBEAN login = new UserBEAN(); try { result = conn.createStatement().executeQuery("SELECT * FROM [tblLogin] WHERE [username] = '" + username + "'; "); while (result.next()) { login.setId(result.getInt("ID")); login.setUsername(result.getString("username")); login.setPassword(result.getString("password")); login.setType(result.getInt("type")); login.setEncrypted(result.getBoolean("encrypted")); if (login.isEncrypted()) { login.setPassword(StringCrypt.decypt(login.getPassword(), Global.KEY)); } } } catch (SQLException e) { e.printStackTrace(); } return login; } }
<br /> The TCP/IP connection to the host :1443, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".<br />
Class
config
config.getUrl()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)