I have wrote a method called "Get_connection" to connect SQL server with my Servlet and i can't use "out.println();" method inside this method even though i passed http servlet Responce as parameters..
Could anyone please explain how to rectify..
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
}
}
public Connection Get_connection() {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1433; databaseName = Colombo_Health; integratedSecurity=true;";
con = DriverManager.getConnection(url, "", "");
out.println("Connection Established");
} catch (ClassNotFoundException e) {
out.println("Class not Found " + e.toString());
e.toString();
} catch (Exception e) {
out.println("Driver not Found " + e.toString());
e.toString();
}
return con;
}