Help Required Please. "Package Java.sql does not Exist"

Soldato
Joined
12 Sep 2003
Posts
11,175
Location
Newcastle, UK
I need some wisdom here guys and gals.

This error is doing my head in, please help. Knowing my luck it's something simple but I can figure out what I'm doing wrong. :o This is in NetBeans IDE 5.5 (for developing mobile Java apps).

Obviously I've installed, jdk1.6.0, j2me, along with jdk1.6.0-docs and NetBeans 5.5 and Mobility Pack. I have added the following lines to my Environment Variable CLASSPATH (the Oracle ones are for Database Connection):-

Code:
C:\Program Files\Java\jdk1.6.0\bin;
C:\Program Files\Java\jdk1.6.0\jre\bin;
C:\Program Files\Oracle\classes12.jar;
C:\Program Files\Oracle\ojdbc14.jar;
D:\Oracle\product\10.2.0\db_1\jdbc\lib\classes12.zip;
D:\Oracle\product\10.2.0\db_1\sqlj\lib\runtime12.jar;
C:\J2ME\bin;
C:\Program Files\Java\jdk1.6.0\lib

also, within Netbeans I have loaded the following:-

NetBeans1.jpg


NetBeans2.jpg



Now it still says the error on the first line, and I have rebooted my machine just incase. However, I have tested the database connection and it works a charm, so I'm actually starting to think do I need to import "java.sql.*" to work with JDBC??? Does NetBeans even support it??? (i.e It's not like JCreator)

Thanks for any help!!! :o
 
Firstly, thanks for the reply, I shall have a look and see if any of those help.

However, after a few days investigating it would appear that if I load rt.jar into the Library, it then works and detects the package java.sql. However, it will not compile because rt.jar is actually found under the jre folder (which is not for development, i.e. jdk).

I have searched my PC incase it is located elsewhere, but it is not. So basically, the errors in the code clear with this file loaded. However, it won't compile because it is not part of J2me or the jdk.

:confused:

Any ideas anybody?!?!
 
From a look on my PC the rt.jar file includes the java.sql package and is part of the standard Java libraries.

I guess it might not be supplied as standard in J2ME as it's not as likely for mobile apps to connect to a relational database and the size of the J2ME footprint needs to be kept as small as possible.

That's my best guess anyway.

Jim
 
JIMA said:
From a look on my PC the rt.jar file includes the java.sql package and is part of the standard Java libraries.

I guess it might not be supplied as standard in J2ME as it's not as likely for mobile apps to connect to a relational database and the size of the J2ME footprint needs to be kept as small as possible.

That's my best guess anyway.

Jim

Hmmm so I wonder how I'm supposed to use it then? You see, I'm trying to connect to a database via JDBC. All on-line guids and Tutorials, load java.sql.* for it to work. When you say you checked your rt.jar on your machine, how did you do this? :o
 
Are you sure you should even be using it? I mean, can mobile phones actually connect directly to databases?

I'm only thinking out loud here, as for part of my coursework my J2ME app needs to get some info from a database. I soon realised it was easier just to make a php script to fetch the data, and use either a StreamConnection or a HttpConnection to get to this page and read the data.
 
I used the Projects pane in NetBeans 5.5 to check the contents of the rt.jar file. This was using a General/Java Application project and JDK 1.5 .

In the Projects pane under the project you'll find a Libraries tree item. Expand this and the first item will be JDK 1.5. Under this you'll see all the Jar files and near the top you'll see rt.jar . If you continue expanding you'll be able to see all the packages within this, java.sql being one of them.

Hope that helps.
Jim
 
KingAdora said:
Are you sure you should even be using it? I mean, can mobile phones actually connect directly to databases?

I'm only thinking out loud here, as for part of my coursework my J2ME app needs to get some info from a database. I soon realised it was easier just to make a php script to fetch the data, and use either a StreamConnection or a HttpConnection to get to this page and read the data.

Hmm interesting, see I wasn't sure I was doing it right, but then I followed a tutorial specifically for this. :confused: But I like what your saying. So basically you are going:-

Mobile App -> PhP Script -> JDBC -> Database

I guess I need Apache running for the script. I'll have to research this HttpConnection method. But I'm guessing that does not need "java.sql.*" to run?

Cheers.
 
JIMA said:
I used the Projects pane in NetBeans 5.5 to check the contents of the rt.jar file. This was using a General/Java Application project and JDK 1.5 .

In the Projects pane under the project you'll find a Libraries tree item. Expand this and the first item will be JDK 1.5. Under this you'll see all the Jar files and near the top you'll see rt.jar . If you continue expanding you'll be able to see all the packages within this, java.sql being one of them.

Hope that helps.
Jim

Cheers Jim!
 
I'll be interested to see if you can get it to work. Because my thought is if J2ME doesn't supply java.sql - and you have to go through this process of importing it.
What happens when you actually transferr this to a mobile phone? You can't tell the mobile phone to import java.sql!
But if you get it to work please reply as I'd be interested to know, although I doubt I'd change

Mine goes something like this:
J2ME -> HttpConnection -> PHP -> MySQL DB

I used the following imports:
import javax.microedition.io.*; //HttpConnection
import java.io.*; // InputStream
 
KingAdora said:
I'll be interested to see if you can get it to work. Because my thought is if J2ME doesn't supply java.sql - and you have to go through this process of importing it.
What happens when you actually transferr this to a mobile phone? You can't tell the mobile phone to import java.sql!
But if you get it to work please reply as I'd be interested to know, although I doubt I'd change

Mine goes something like this:
J2ME -> HttpConnection -> PHP -> MySQL DB

I used the following imports:
import javax.microedition.io.*; //HttpConnection
import java.io.*; // InputStream

Well I've followed some more basic tutorials, removed and reinstalled the java stuff again (and only used what I need) and started using the Wireless Development Kit 2.5 along with Apache Tomcat.

I've managed to create a MIDlet which connects to a Servlet which replies with the amounts of hits it's had to the mobile phone. Pretty cool, but I should be able to alter the tutorial work to connect to a database I would have thought.

So hopefully this way will be a bit better... we shall see. :)
 
Back
Top Bottom