• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

package does not exists?

Hi , experts I downloaded some jarfiles for accessing as400 db2 database
and wheather  I run it as a jsp or when I edit it using NetBeans  as a servlet class it appears package does not exists,
"com.ibm.as400.access ", I just tried by using "import com.ibm.as400.access.*;" with same bad  results
With the   Net beans Ide I added the jar files as Libraries and when I check them out (the jt400 from inside) it shows up the full path completed

jt400.jar:
com
      ibm
            as400
                     access
                                as400JDBCDRIVER.class


but anyHoww when I want to compile it using net beans it shows class not found
(as400JDBCDRIVER.class) and if I import the com.ibm.as400.access.*; I get this error "package does not exists"

I downloaded the  jars and I put them in a folder I just called IBMJTOPEN(just a name) where I unzipped them at
I added the jars path to my class path
--------------------------------------------------------------------------------
%classpath%;C:\WINNT\java\Packages;C:\jakarta-tomcat-5.0.28\common\lib\servlet-api;C:\jakarta-tomcat-5.0.28\common\lib\jsp-api;C:\IBMJTOPEN\lib\jt400.jar;C:\IBMJTOPEN\lib\util400.jar;C:\IBMJTOPEN\lib\jt400Servlet.jar;C:\IBMJTOPEN\lib\util400.jar;C:\IBMJTOPEN\lib\jt400Servlet.jar;C:\IBMJTOPEN\lib\composer.jar;C:\IBMJTOPEN\lib\jt400micro.jar;C:\IBMJTOPEN\lib\jt400Proxy.jar;C:\IBMJTOPEN\lib\jt400Servlet.jar;C:\IBMJTOPEN\lib\jui400.jar;C:\IBMJTOPEN\lib\outputwriters.jar;C:\IBMJTOPEN\lib\reportwriter.jar;C:\IBMJTOPEN\lib\tes.jar;C:\IBMJTOPEN\lib\uitools.jar;
---------------------------------------------------------------------------
The code I use is :


try {
            DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
                     conn = DriverManager.getConnection("jdbc:as400://" + system, username, password);
             DatabaseMetaData dbMetaData = conn.getMetaData();
             conn.close();

           
            }
            catch (SQLException e){System.out.println(e.getMessage());e.printStackTrace () ;}
            catch (ClassNotFoundException e){System.out.println(e.getMessage());e.printStackTrace () ;}
     
     return conn;

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

Help!!!!
0
edwbear1976a
Asked:
edwbear1976a
8 Solutions
 
Tommy BraasCommented:
You need to ensure that the jar file is on both the build classpath AND the classpath for when you execute your code.
0
 
Tommy BraasCommented:
Oops...answered too fast.

You should NEVER reference a driver directly in your code. Use the following code instead:

Class.classForName("com.ibm.as400.access.AS400JDBCDriver");

0
 
Tommy BraasCommented:
Instead of             DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
mrigankCommented:
Try writing AS400JDBCDriver as as400JDBCDriver
0
 
CEHJCommented:
Please post the output of

jar tf your.jar

(making obvious adjustments to the name of the jar file)
0
 
objectsCommented:
try adding the jars to your jre ext directory instead of adding them to your classpath
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Many IBM classes actually had 'IBM' in capital case in their names. Try with com.IBM instead of com.ibm. Also, you should keep the driver class-name in a properties-file or a configuration-file and read from it, instead of hard-coding it in the code
0
 
Giant2Commented:
Try to use your Netbeans/Eclipse/Jbuilder and type the full class name.
The GUI help you suggesting the correct name (capital/lower letter and so on). Be sure you have the jar file in the classpath.
In this manner you are sure not make a mistake in the classpath/classname.

Hope this could help you.
Bye, Giant.
0
 
edwbear1976aAuthor Commented:
well, thank you all for your advices, the problem is solved, I changed the reference  to the driver as orangehead911 said and I also  put the jar file in the  jre ext directory as object adivised me , I'm going the increase the points to split
thank you all buds
0
 
CEHJCommented:
:-)
0
 
Tommy BraasCommented:
;-D
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now