Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection can not be resolved

 
ankur mawandia
Greenhorn
Posts: 12
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Markas Korotkovas
Greenhorn
Posts: 21
Eclipse IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ankur mawandia
Greenhorn
Posts: 12
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some one tell me please why my connection class can not be resolved
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • 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
    Posts: 12
    Eclipse IDE Java Postgres Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 64833
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    No, the code is still in a JSP.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic