We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

package does not exists?

edwbear1976a
edwbear1976a asked
on
Medium Priority
582 Views
Last Modified: 2008-01-09
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!!!!
Comment
Watch Question

You need to ensure that the jar file is on both the build classpath AND the classpath for when you execute your code.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
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");

Instead of             DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
Commented:
Try writing AS400JDBCDriver as as400JDBCDriver
CERTIFIED EXPERT
Top Expert 2016
Commented:
Please post the output of

jar tf your.jar

(making obvious adjustments to the name of the jar file)
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
try adding the jars to your jre ext directory instead of adding them to your classpath
Mayank SPrincipal Technologist
CERTIFIED EXPERT
Commented:
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
Commented:
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.

Author

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
CERTIFIED EXPERT
Top Expert 2016

Commented:
:-)
;-D
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.