|
1) Is it impossible to use a DB2 JDBC driver if you have DB2 installed on the NT PC on which you're running VAJ? You could use the JDBC driver shipped with DB2 on the NT PC and it would talk to either the local DB2 database or I assume it could talk to the real AS/400 database via DRDA. I don't suggest you do this. You can't use the Native JDBC driver shipped with the 400/iSeries from NT (that I know of - and I wrote it so it seems unlikely. Perhaps VAJ remote support for debugging... perhaps there is something there). The suggestion I have is to plan to develop/test with the Toolbox JDBC driver in VAJ and move to the Native JDBC driver for performance on the host. 2) so there's potentially incompatibility between the development (NT) & test/live (AS/400) JDBC drivers. True, but we are trying very hard to eliminate these. If incompatibilities between the drivers are brough to our attention (this group would be a fine place to do so - or e-mail me), we try to resolve them right away where possible. You might not always like the resolution, we might decide that the driver that you were coding to is the one that needs to change for specification compliance, performance or other reasons. But we are trying to get them to be very similar in functionality. We use a common test bucket for the two drivers that has about 7,000 tests of the various interfaces and we work closely on new features (like JDBC 3.0 support). The drivers are not identical. They probably never will be. But by comparison, we do relatively little comparison testing with the JDBC drivers shipped for other platforms (UDB on NT for example). There are many more subtle differences that can creep in when you go that route. 3) You also, although it may seem a trivial point, don't have to mess about with the classpath. This is a good time to be able to point out that the native JDBC driver is in the classpath automatically only when you are running on JDK 1.1.X. With JDK 1.2 and beyond, the Native JDBC driver is a JVM extension. Its still shipped with the system and ready for use, but there is a one time setup that is needed to 'register' the driver in the extensions directory. Here is a new entry that will be added to our faq in the short term future. (The faq is at http://www.as400.ibm.com/developer/jdbc/Faqs/JDBCFAQ.html). If there are things that are not in the faq that should be, please e-mail them to me. I have a list of a couple new items that I am maintaining for when I have a rainy day - which almost never happens in Rochester. :) B19. How do I get the native JDBC driver to be found in JDK 1.2 and beyond? In JDK 1.2, functions like JDBC, SSL, and JNDI are JDK extensions. To use a JDK extension, first find the ".jar" file in the '/QIBM/ProdData/Java400/ext/' directory. Then, a symbolic link needs to be established once to make the files a part of the '/QIBM/UserData/Java400/ext/' directory. This is so that the class loader can find them. For example, to establish the symbolic link for JDBC, use the following command: Pre-V5R1: ADDLNK OBJ('/QIBM/ProdData/Java400/ext/db2_classes.jar') NEWLNK ('/QIBM/UserData/Java400/ext/db2_classes.jar') V5R1 and Later: ADDLNK OBJ('/QIBM/ProdData/OS400/Java400/ext/db2_classes.jar') NEWLNK ('/QIBM/UserData/Java400/ext/db2_classes.jar') Note: WebSphere 3.6 will create this link automatically if it does not exist, otherwise it will have to be done by hand. If you need to use JDBC 2 Optional Package features in your application (like DataSources), add this link: ADDLNK OBJ('/QIBM/ProdData/Java400/ext/jdbc2_0-stdext.jar') NEWLNK ('/QIBM/UserData/Java400/ext/jdbc2_0-stdext.jar') If you need to use JTA (Java Transaction API) features in your application, add this link: ADDLNK OBJ('/QIBM/ProdData/Java400/ext/jta-spec1_0_1.jar') NEWLNK ('/QIBM/UserData/Java400/ext/jta-spec1_0_1.jar') Regards, Richard D. Dettinger AS/400 Java Data Access Team "Biologists have a special word for stability -- dead" Larry Wall Open Source Developers Journal Issue 1, Jan 2000 mandy.shaw@uk.catalyst-solutions.com@midrange.com on 02/13/2001 05:30:24 PM Please respond to JAVA400-L@midrange.com Sent by: owner-java400-l@midrange.com To: JAVA400-L@midrange.com cc: Subject: Re: DB2 JDBC native driver Is it impossible to use a DB2 JDBC driver if you have DB2 installed on the NT PC on which you're running VAJ? One of my customers is thinking of giving this a whirl. I have encouraged him to use the Toolbox instead. He is using the native DB2 driver on AS/400 for the live app, so there's potentially incompatibility between the development (NT) & test/live (AS/400) JDBC drivers. I have pointed out that there'll probably be incompatibility between NT & AS/400 versions of the DB2 driver anyway, & that testing the particular aspects of JDBC used (basically, stored procedures with various combinations of in, out, inout parameters and/or result sets) against both drivers with a special test harness is probably the answer. (I have encountered large numbers of incompatibilities in the past between OS/400 releases and PTF levels, before you even worry about whether it's DB2 or Toolbox.) Perhaps other people who are in this situation of having to use different JDBC drivers for dev & live could comment on what they've encountered, as well? Incidentally I originally advised him to use of the DB2 driver in the live environment, fundamentally because it's running over SNA for security and the Toolbox doesn't support SNA, but also because our experience indicates much better performance than with the Toolbox, even when the latter is optimised to level 40. You also, although it may seem a trivial point, don't have to mess about with the classpath. Mandy cujo@us.ibm.com on 12/02/2001 14:53:36 Please respond to JAVA400-L@midrange.com To: JAVA400-L@midrange.com cc: (bcc: Mandy Shaw/Pacific/UK) Subject: Re: DB2 JDBC native driver You wrote: "Basically I want to develop and debug my code inside IDE (VisualAge) by using DB2 native JDBC driver. " You can't (to the best of my knowledge). Perhaps there is remote debug support to some degree that you really can do this, but I am not wise enough in the VAJ world to know it. If someone knows how to make this work, please assist. Now, unless someone says that VAJ can do this, here is why. The native JDBC driver in its primary static initializer (you can't even create an object before this happens), starts talking directly to the CLI on which its built. There is no network, the APIs talk directly to each other. You can get from one AS/400 to another system by a lower level network layer (DRDA). Today, you just can't escape the fact that the "client" system *must* be an AS/400. Even if you found a way to piece the parts together so it would work on a different CLI/ODBC implementation, you would run into all kinds of problems because ODBC/CLI is not nearly as portable as JDBC drivers are. What you probably want to do, in light of this is build your application around the Toolbox JDBC driver. Then simply plug the Native JDBC driver in when you move your application. This solution is perhaps not the best, and it might require a bit more isolated testing after primary development is done, but the approach works pretty seamlessly for most people. If there are differences in the way the JDBC API works between the two drivers, they should be posted to us here and we will investigate them. That doesn't mean we can work all of them out, but they should appear pretty identical to application code. Regards, Richard D. Dettinger AS/400 Java Data Access Team "Biologists have a special word for stability -- dead" Larry Wall Open Source Developers Journal Issue 1, Jan 2000 "Xu, Weining" <Weining.Xu@AIG.com>@midrange.com on 02/12/2001 08:14:40 AM Please respond to JAVA400-L@midrange.com Sent by: owner-java400-l@midrange.com To: "'JAVA400-L@midrange.com'" <JAVA400-L@midrange.com> cc: Subject: DB2 JDBC native driver You wrote: 2) To the best of my knowledge, the native JDBC jar file is not in VisualAge anywhere. You can always take the jar file noted above and put it in VisualAge but for most purposes, this isn't really needed because you would already be coding to the JDBC API interface. I imported db2_classes.jar into a project called DB2 inside VisualAge environment. I have "import com.ibm.db2.jdbc.app.*;" for my class. I checked the classpath to DB2 project. But when I run the program, it seems still cannot load "com.ibm.db2.jdbc.app.DB2Driver". What could be wrong? Basically I want to develop and debug my code inside IDE (VisualAge) by using DB2 native JDBC driver. Then deploy them on AS/400, so the production programs will be run on AS/400 machine. I do not have problem on AS/400 yet. Thanks, Wayne -----Original Message----- From: Richard Dettinger [mailto:cujo@us.ibm.com] Sent: Monday, February 05, 2001 11:40 AM To: JAVA400-L@midrange.com Subject: RE: Updating result set in Java This should help: 1) The native JDBC driver is not in the classpath be default with JDK 1.2 and beyond. The following CL command will put the Native JDBC driver in your extensions classpath and then you won't have to worry about it again: ADDLNK OBJ('/QIBM/ProdData/Java400/ext/db2_classes.jar') NEWLNK ('/QIBM/UserData/Java400/ext/db2_classes.jar') Of course, you can just add it to your classpath if you want. That will fix the no suitable driver messages. 2) To the best of my knowledge, the native JDBC jar file is not in VisualAge anywhere. You can always take the jar file noted above and put it in VisualAge but for most purposes, this isn't really needed because you would already be coding to the JDBC API interface. 3) You can't run the native JDBC driver from a system that is not a 400 (iSeries). This is because it is tied directly into the database and the JVM. You can connect from one 400 to another 400 or from one 400 to a different backend (such as a 390) over DRDA, but you can't have your 'client' not be an AS/400 or iSeries. Regards, Richard D. Dettinger AS/400 Java Data Access Team "Biologists have a special word for stability -- dead" Larry Wall Open Source Developers Journal Issue 1, Jan 2000 "Xu, Weining" <Weining.Xu@AIG.com>@midrange.com on 02/05/2001 10:08:19 AM Please respond to JAVA400-L@midrange.com Sent by: owner-java400-l@midrange.com To: "'JAVA400-L@midrange.com'" <JAVA400-L@midrange.com> cc: Subject: RE: Updating result set in Java Thanks, Richard. As you suggested, I am running the program on AS/400 by using DB2 native JDBC driver. Now I got other problems on AS/400. I have multiple JDKs on the AS400. In order to use the JDBC 2.0 API, I have to use JDK 1.2. But I got "no suitable driver" message. I have no problem to load the driver if I run the program using JDK1.1.8, of course in this case all JDBC2.0 API methods will not be recognized. Does AS400 Developer Kit for Java only support JDK1.1.8? Do I miss something here? By the way, I tried to run the db2 JDBC native driver inside VisualAge for JAVA 3.5. But the program can not find the driver. Do you know where is the package "com.ibm.db2.jdbc.app" inside the IDE. I have no problem to use the native driver on AS400 (for JDK1.1.8). What I understood is that on AS400 I am using AS/400 Developer Kit for Java, how about inside VisualAge? I do have write authority to the table. In fact, I can use SQL statement to update the ID field of the TEST table. The code looks like this: String myUpdate = "update TEST set ID = RRN(TEST)+30"; stmt = con.createStatement(); stmt.executeUpdate(myUpdate); Thanks. -----Original Message----- From: Richard Dettinger [mailto:cujo@us.ibm.com] Sent: Monday, February 05, 2001 9:11 AM To: JAVA400-L@midrange.com Subject: RE: Updating result set in Java You don't have write authority to the table??? No, I don't have another guess. Export your program to the 400 and use the Native JDBC driver to see if the problem is the same. If the problem is the same, the issue is likely to be something about the database (either setup or a bug). If it works that way, its likely to be a Toolbox JDBC driver issue which should be investigated. Regards, Richard D. Dettinger AS/400 Java Data Access Team "Biologists have a special word for stability -- dead" Larry Wall Open Source Developers Journal Issue 1, Jan 2000 "Xu, Weining" <Weining.Xu@AIG.com>@midrange.com on 02/02/2001 03:52:00 PM Please respond to JAVA400-L@midrange.com Sent by: owner-java400-l@midrange.com To: "'JAVA400-L@midrange.com'" <JAVA400-L@midrange.com> cc: Subject: RE: Updating result set in Java rs.next() did return true. The code was simplified. I do use while (rs.next()) in my real code. any other thought?? -----Original Message----- From: Richard Dettinger [mailto:cujo@us.ibm.com] Sent: Friday, February 02, 2001 4:23 PM To: JAVA400-L@midrange.com Subject: Re: Updating result set in Java Are you sure the call to rs.next() returned true? If you don't test the boolean return value, the resultset could have been empty. That's my first, best guess. Of course, you can write code however you want, but I always make it a practice to use while(rs.next()) if I am going to process all the rows and if (rs.next()) if I want to process only one. This ensures that there is always data before I go off and try to do something to the ResultSet. Regards, Richard D. Dettinger AS/400 Java Data Access Team "Biologists have a special word for stability -- dead" Larry Wall Open Source Developers Journal Issue 1, Jan 2000 "Xu, Weining" <Weining.Xu@AIG.com>@midrange.com on 02/02/2001 02:29:04 PM Please respond to JAVA400-L@midrange.com Sent by: owner-java400-l@midrange.com To: "'JAVA400-L@midrange.com'" <JAVA400-L@midrange.com> cc: Subject: Updating result set in Java I have problem to update the result set programmatically. I use VisualAge for Java 3.5 Enterprise Edition. My database is DB2 in AS/400. I am using JDBC 2.0 API features to update the field in the result set. I got error message: SQLException: Cursor state not valid. SQLState: 24000 Here is my sample code: import java.sql.*; import com.ibm.as400.access.*; class Test { public static void main(java.lang.String[] args) { Connection con = null; Statement stmt = null; ResultSet rs = null; // Load Java JDBC driver. try { Class.forName("com.ibm.as400.access.AS400JDBCDriver"); } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "+e.getMessage ()); } try { con = DriverManager.getConnection ("jdbc:as400://wilm620/agtcomp", "myID", "mypassword"); } catch (SQLException e){ System.err.println("Connection Error Exception: " +e.getMessage()); } try{ stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = stmt.executeQuery("select ID from AGTCOMP.TEST"); //move the cursor to the first row and update the ID field (Integer) to 30. rs.next(); rs.updateInt(1,30); stmt.close(); con.close(); }catch (SQLException e){ System.err.println("SQLException: "+e.getMessage()); System.err.println("SQLState: "+e.getSQLState()); } System.exit(0); } } I have tried to scroll the result set up and down, there is no problem to do that. But I just cannot update it. Of course I can not do rs.updateRow() to update the row in the database either. Any helps will be highly appreciated. Weining (Wayne) Xu Phone: +302.594.2846 Email: weining.xu@aig.com +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- Regards, Mandy Shaw Catalyst Solutions plc Kingfisher House Frimley Business Park Camberley Surrey GU16 5SG UK http://www.catalyst-solutions.com Email: Mandy.Shaw@uk.catalyst-solutions.com Telephone: +44 (0)870 166 1000 DDI: +44 870 166 1324 Facsimile: +44 870 168 3920 Mobile: +44 410 447966 ---------------------------------------------------------------------- ---------------------------------------------------------------------- Catalyst Solutions plc. Registered No 2918101. Registered @ Kingfisher House, Frimley Business Park, Frimley, Surrey. GU16 5SG U.K. NOTICE: This message is intended only for the named addressee(s) and may contain confidential and/or privileged information. If you are not the named addressee you should not disseminate, copy or take any action or place any reliance on it. If you have received this message in error please notify postmaster@catalyst-solutions.com and delete the message and any attachments accompanying it immediately. ---------------------------------------------------------------------- +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +---
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.