|
I assume you are trying to run this on the iSeries and not the client. Given that, your code looks pretty valid. The Java class loader with the latest JV1 PTFs should automatically find the native JDBC driver (you don't have to put anything in any classpath anywhere). So you might want to ensure your PTFs are up to date. Alternatively, you can ensure that you have the symlink to the db2_classes.jar file in your extensions classpath by hand. You create a symlink to it. The CL command to accomplish this looks something like this: ADDLNK OBJ('/QIBM/ProdData/OS400/Java400/ext/db2_classes.jar') NEWLNK ('/QIBM/UserData/Java400/ext/db2_classes.jar') Richard D. Dettinger AS/400 Java Data Access Team Democracy's enemies have always underestimated the courage of the American people. It was true at Concord Bridge. It was true at Pearl Harbor. And it was true today. Rochester Post-Bulletin Tuesday September 11, 2001 "Mike Silvers" <msilvers@hbs-inc.com>@midrange.com on 11/20/2001 05:37:36 PM Please respond to java400-l@midrange.com Sent by: java400-l-admin@midrange.com To: "Java 400-L" <java400-l@midrange.com> cc: Subject: JDBC runtime error.... Hi All. I am using JDBC for data connectivity. The class for database connectivity compiles with no problem. When I run the class, I receive an error. Does anyone have any ideas? The error I receive: java.lang.NoClassDefFoundError java/lang/ClassLoader.defineClass(Ljava/lang/String;[BIILjava/security/Prote ctionDomain;)Ljava/lang/Class;+79 (ClassLoader. java:486) java/net/URLClassLoader.defineClass(Ljava/lang/String;Lsun/misc/Resource;)Lj ava/lang/Class;+196 (URLClassLoader.java:270) java/net/URLClassLoader$ClassFinder.run()Ljava/lang/Object;+42 (URLClassLoader.java:572) java/net/URLClassLoader.findClass(Ljava/lang/String;)Ljava/lang/Class;+16 (URLClassLoader.java:198) java/lang/ClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;+41 (ClassLoader.java:297) sun/misc/Launcher$AppClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Cl ass;+33 (Launcher.java:286) java/lang/ClassLoader.loadClassInternal(Ljava/lang/String;)Ljava/lang/Class; +1 (ClassLoader.java:313) My JDBC code is as follows: private void connectDB() { // register the driver try { Class.forName("com.ibm.db2.jdbc.app.DB2Driver"); } catch (Exception e) { System.out.println("Exception at Class.forName \n" + e); } // connection info - set the library too..... String userId = "TESTUSR"; String password = "testpass"; String url = "jdbc:db2:localhost/IPINFO"; // connect to the 400 try { p.put("user", userId); p.put("password", password); c = DriverManager.getConnection(url,p); } catch (Exception e) { System.out.println("Connection problem"); e.printStackTrace(); } catch (NoClassDefFoundError ncl) { System.out.println("No Class Found \n" + ncl); } } ================================ Mike Silvers AS/400 Senior Programmer/Analyst AS/400 IBM Certified RPG IV Developer AS/400 IBM Certified Expert Hainey Business Systems 8 E. Canal St Dover, PA 17315 Branch Office: (410) 397-8739 Phone: (800) 932-3380 Fax: (717) 292-9474 Web: http://www.hbs-inc.com ________________________________ Providing E-Commerce, EDI, AS/400 Development and related services nationwide. ================================ _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.