Link to home
Start Free TrialLog in
Avatar of asidu
asiduFlag for Singapore

asked on

IBM Universe database connectivity problem in java

I am trying to access data from IBM Universe database (running on HP UNIX) using Java code.  

I am using UniJDBC driver to access this data.

Following is my program to access the data:

import java.sql.*;

public class myUltracs {
    public myUltracs() {
    }
    public static void main(String[] args) {
        Connection con=null;
        Statement stmt;
        try
        {
            Class.forName("com.ibm.u2.jdbc.UniJDBCDriver").newInstance();
            con=DriverManager.getConnection("jdbc:ibm-u2://<ip addr>//<database>","uname","pwd");
            stmt=con.createStatement();
            ResultSet rs=stmt.executeQuery("select @ID from TABLE");
            while(rs.next())
                System.out.println("Value="+rs.getString(1));
            rs.close();
            stmt.close();
            con.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}

Following is the run-time error:
java.sql.SQLException: Failure to login as remote user

Connection using ODBC Data Source Administrator works fine, but through java programming generates run time error.  

What could be the possible cause for this?
Avatar of momi_sabag
momi_sabag
Flag of United States of America image

are you sure that the username and password you provide are valid ?
can you connect using those username and password from the db2 command line ?
Avatar of asidu

ASKER

I tried establishing connectivity using ODBC (thru windows ODBC data source administrator) with the same username and password everything seems to be ok.

what happens if you try to use the command center ?
can you do it ?
Avatar of asidu

ASKER

Hi momi_sabag:

Thanks for your time and effort in analyzing my problem.

I have no much exposure to the command line, so if you can advice me one that it will be much appreciated.

And also i tried changing the connection url (jdbc:ibm-u2://<ip addr>//<database) to (jdbc:ibm-u2://<ip addr>:<port>//<database) by specifying the port number.  When i compiled the program everything seems to be ok, but this time again a runtime error is generated saying "Java Heap Size error", i even tried increasing the heap memory size and also fetched only one record from the database but even then same heap memory problem.

But if you guide me how to check on IBM Universe command line to check the connectivity then i can come to a conclusion.

Thanks.



ASKER CERTIFIED SOLUTION
Avatar of momi_sabag
momi_sabag
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of asidu

ASKER

Hi Steven,

Thanks for your reply.  Unfortunately there is no Universe db administrator to enable JDBC/SQL access.  So if you can guide me how to go about it, it will be of great help.
Avatar of asidu

ASKER

Now i am able to establish connection with database, but when i am trying to access records from file named CUSTOMER, i get sql exception error stating unable to open file.

I even tried changing file permission to full access, but doenst help.

Following is the error message:

java.sql.SQLException: Unable to open "/MYDB/CUSTOMER" file.
        at com.ibm.u2.jdbc.UniJDBCMsgFactory.createException(UniJDBCMsgFactory.java:89)
        at com.ibm.u2.jdbc.UniJDBCExceptionSupport.addException(UniJDBCExceptionSupport.java:87)
        at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.addServerError(UniJDBCProtocolU2Impl.java:2519)
        at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.associateServerCursor(UniJDBCProtocolU2Impl.java:1479)
        at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.associateCursor(UniJDBCProtocolU2Impl.java:1524)
        at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.prepare(UniJDBCProtocolU2Impl.java:1705)
        at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.doExecuteAll(UniJDBCProtocolU2Impl.java:2069)
        at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.executeStatementQuery(UniJDBCProtocolU2Impl.java:563)
        at com.ibm.u2.jdbc.UniJDBCStatementImpl.executeQuery(UniJDBCStatementImpl.java:208)
        at jdbcsample.testQuery(jdbcsample.java:86)
        at jdbcsample.main(jdbcsample.java:52)

Any help on this is much appreciated.

Avatar of asidu

ASKER

Hi All,

I finally managed to make my program work.  The problem is with the file permission and login account.  Now i can view records.

But, when i am trying to update records, i get the following message:

Universe/SQL: Correlative are illegal for UPDATE

I cannot understand much from this message.  Any assistance on this will be much appreciated.

Avatar of ashwin197816
ashwin197816

what is you UPDATE query?