*
The moose likes JDBC and the fly likes connection can not be resolved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "connection can not be resolved" Watch "connection can not be resolved" New topic
Author

connection can not be resolved

ankur mawandia
Greenhorn

Joined: Jan 10, 2011
Posts: 12

i 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




the jsp page i have 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:



thnx in advance


may the force be with you
Markas Korotkovas
Greenhorn

Joined: Jan 27, 2011
Posts: 21

You should never perform database operations directly in the JSP. All the DB connection and query stuff needs to be moved to lower level of application: servlet or the special Data Access Object.

As far as the connection problems themselves, the question is probably more appropriate in the JDBC forum
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

As this has nothing to do with JSP, and the code shouldn't even be in the JSP as noted, this has been moved to the JDBC forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ankur mawandia
Greenhorn

Joined: Jan 10, 2011
Posts: 12

Can some one tell me please why my connection class can not be resolved
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

  • Move the code out of a JSP and into a Java class.
  • Place all Java classes in a package other than the default.
  • Maker sure your class files are placed in the correct folder under WEB-INF.
  • ankur mawandia
    Greenhorn

    Joined: Jan 10, 2011
    Posts: 12

    i have created a folder connect in my WEB-INF directory and placed my java and class files there

    and
    <%@ page import="connect.Jdbcconnections" %>

    is this correct
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60780
        
      65

    No, the code is still in a JSP.
     
     
    subject: connection can not be resolved
     
    Similar Threads
    Problem loading the class
    Cannot Compile Class error on Tomcat 6.0
    JavaMail Session cannot be resolved to a type
    handling wrong data type entry through servlet
    error in jsp(please help)