0

am trying to connect a jsp page to a postgress database
i have created a jdbcconnects.java file and compiled it with jsp_api.jar from my apache..../lib directory

i have placed the class file in root/WEB-INF/classes folder

the code of my class file is

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class Jdbcconnections {

  public Connection connect()throws Exception {
    Connection con = null;
    
    try {
     Class.forName ("org.postgresql.Driver");
      con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/EMPPWD", "postgres", "ankur");
     

           
   } catch(Exception e) {
      System.err.println("Exception: " + e.getMessage());}
	   return con;
   }

 
}

in the jsp page i have written

<%@ page import="Jdbcconnections" %>
  Jdbcconnections obj=new Jdbcconnections();  
      Connection con;  
      con=obj.connect();
1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by ankurmawanda
0

the error is


i am getting a


An error occurred at line: 7 in the generated java file
The import Jdbcconnections cannot be resolved

An error occurred at line: 14 in the jsp file: /payroll/ddoregisters.jsp
Jdbcconnections cannot be resolved to a type
11: <%@ page import="Jdbcconnections" %>
12: <%
13:
14: Jdbcconnections obj=new Jdbcconnections();
15: Connection con;
16: con=obj.connect();
17:


An error occurred at line: 14 in the jsp file: /payroll/ddoregisters.jsp
Jdbcconnections cannot be resolved to a type
11: <%@ page import="Jdbcconnections" %>
12: <%
13:
14: Jdbcconnections obj=new Jdbcconnections();
15: Connection con;
16: con=obj.connect();
17:

Edited by ankurmawanda: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.