• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Not importing java.sql.*

 
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.
 
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
 
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.
------------------
 
Ranch Hand
Posts: 1871
  • 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: 1871
  • 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)
 
Ranch Hand
Posts: 1512
  • 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
 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic