• Post Reply Bookmark Topic Watch Topic
  • New Topic

Not importing java.sql.*  RSS feed

 
Ghazala Islam
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three import statements in my jsp
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
When I run jsp without import java.sql.* statement,it works fine but when I include this statement it doesn't run and give error.
whats the problem?Please guide.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ghazala Islam:
...When I run jsp without import java.sql.* statement,it works fine but when I include this statement it doesn't run and give error.
whats the problem?Please guide.

Difficult to diagnose without knowing what the error was, but I'm betting its a problem with java.util.Date and java.sql.Date
Can we meet in the middle? You give us some more info and we'll try to solve your problem
(not going to give a big explaination if this isn't the problem)
Dave
 
rudayashanker
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi it works fine for me for the above package...please give u me a specific problem where it is not working....

Thanx
Shankar.
------------------
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The jsp specification 1.2 in page 50 clearly specifies
The default import list is the java.lang.*;
javax.servlet.*;
javax.servlet.jsp.*;
javax.servlet.http.*;
so your jsp should not have worked. Have you imported the sql package in one of the included jsps. Just check up.

------------------

Mahindrakar
IBM Application Server Forum Moderator

Consultant - Zensar Technologies ,Pune India.
SCJP2, SCJD2 & SCJEA (Part I)
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"rudayashanker"
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
------------------

Mahindrakar
IBM Application Server Forum Moderator

Consultant - Zensar Technologies ,Pune India.
SCJP2, SCJD2 & SCJEA (Part I)
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly what's the text of the error? Like David said, it's most likely an issue with the Date class being in both java.util and java.sql. If it's the date issue, just use the full qualified name to indicate which one you are actually referring to.

Bosun

 
Ghazala Islam
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Thanx for help.You people asked about error.I have used
new date(),so its giving error like Ambiguous class:java.sql.date and java.util.date.I think both packages have date classes,but why?
Congrats to dave for winning the bet!
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ta da!
Short answer: You'll have to explicitly declare the class you want to create, otherwise it doesn't know which one (like Bosun was saying)
So either of these:

The longer answer is explicitly implort any class you want and don't use the "import java.xxx.*"
Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!