hi i want to connect to the database therefore i wrote a database class
package PlotManagement;
import java.sql.*;
public class DBConnection {
public Connection connection =null;
public Connection connect()
{
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
String connectionUrl = "jdbc:jtds:sqlserver://DCSRV02:1433/REGISTRATION_TEMP_LTR_PRINT";
connection = DriverManager.getConnection(connectionUrl,"sa","water");
System.out.println("Connected" );
}
catch (Exception e)
{
System.out.println( "<h1>exception: "+e+e.getMessage()+"</h1>" );
e.printStackTrace();
}
return connection;
}
}
and i am trying to use connection variable in my
servlet package PlotManagement;
import java.io.*;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.*;
import javax.servlet.http.*;
public class GetAreacode extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title> Films Example: Servlet, MSSQL version</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">");
try {
DBConnection d= new DBConnection();
Statement stmt = d.connection.createStatement();
ResultSet rs;
rs = stmt.executeQuery("select areacode from areacodemaster");
out.println( "<table>" );
while ( rs.next() )
{
String areacode = rs.getString(1);
out.println("<tr><td>"+areacode+"</td></tr>");
}
out.println( "</table>" );
d.connection.close();
}
catch (Exception e)
{
out.println( "<h1>exception: "+e+e.getMessage()+"</h1>" );
e.printStackTrace();
}
out.println("</body>");
out.println("</html>");
}
}
But i am getting the following errors
GetAreacode.java:23: cannot find symbol
symbol : class DBConnection
location: class PlotManagement.GetAreacode
DBConnection d= new DBConnection();
^
GetAreacode.java:23: cannot find symbol
symbol : class DBConnection
location: class PlotManagement.GetAreacode
DBConnection d= new DBConnection();
^
2 errors
can any 1 suggest me whats wrong here.