× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



hi,

i got a little problem i was pondering about some days now and i still
don't now why it is like that.

i got a class RootAccess through which i would like to get some data
from our DB2/400.

it looks like this:

public class RootAccess
{
        DatabaseMetaData dmd;
        Connection connection;
        ResultSet rs;
        Statement statement;
        String stm;

        public RootAccess()
        {
                try
                {
                        DriverManager.registerDriver(new
AS400JDBCDriver());
                        connection = DriverManager.getConnection
("jdbc:as400://PORTA","user","pwd");
                        dmd = connection.getMetaData();
                        statement = connection.createStatement();
                }
                catch (SQLException sqle)
                { 
                        System.out.println("Problems during database
connection initialization.");
                        System.out.println(sqle.getLocalizedMessage());
                }
        }
                
        public String getCompanyName(int companyID)
        {
                stm = "Select VDDAT from UDVM400DAT.MVDATR where VDSAA =
3 and VDFIR = 10";

                try
                {
                        statement.executeQuery(stm);
                        if(rs != null)
                        {
                                rs.next();
                                return rs.getString(1).trim();
                        }
                        return "";
                }
                catch(SQLException sqle)
                {
                        System.out.println(sqle.getLocalizedMessage());
                        return "";
                }
                finally
                {
                        rs = null;
                }
        }

        public Vector getCompanyNames()
        {
                Vector namesVec = new Vector();
                
                stm = "Select substring(VDDAT,1,20)  from
UDVM400DAT.MVDATR where VDSAA = 3";
                
                try
                {
                        rs = statement.executeQuery(stm);
                        
                        if(rs != null)
                        {
                                while (rs.next())
namesVec.add(rs.getString(1).trim());
                        }               
                }
                catch (SQLException sqle)
                {
                        
                }
                finally
                {
                        rs = null;
                }
                
                return namesVec;
        }
}


my main class looks like this:

public class Test
{
        public static void main(String[] args)
        {
                RootAccess access = new RootAccess();
                
                System.out.println("Firmengruppe 010:" +
access.getCompanyName(10));

                Vector vec = access.getCompanyNames();
                
                for (int i = 0; i < vec.size(); i++)
                {
                        System.out.println("Firmengruppenname:" +
vec.get(i).toString());
                }
        }
}

now my problem:
when i execute the first method, the result set is null. if execute the
same sql statement via several other applications or directly on the
as400 i get the right result (not null).
but when i execute the second method i get the right results.
now why does the first sql request doesn't work. did i forgot something?

os400 v4r5
java (on pc) ibm 1.3.0
jtopen 3.1


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.