[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

IBM Universe database connectivity problem in java

Posted on 2007-10-17
12
Medium Priority
?
2,487 Views
Last Modified: 2008-09-17
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?
0
Comment
Question by:asidu
10 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 20093331
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 ?
0
 
LVL 12

Author Comment

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

0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 20099533
what happens if you try to use the command center ?
can you do it ?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 12

Author Comment

by:asidu
ID: 20099715
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.



0
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
ID: 20099820
the command line work the same way as odbc, so if odbc works, the command line will probably work too, but just for your knowledge you open the command line processor through the program menu and then you can issue - connect to <db-name> command.
i think you should try to use the control center (you can reach it through the program menus or just invoke db2cc from the start-> run prompt') since it is written in java so it should work
another thing you should check is the supplied ibm sample
you can find them under
/program files/sqllib/samples/java
if their samples work, there might be something wrong with your code
0
 
LVL 3

Assisted Solution

by:stevengmoreau
stevengmoreau earned 500 total points
ID: 20988902
This problem is being caused due to the fact that the Universe Account and file (table) that you are trying to read from has not been enabled for JDBC/SQL access. You should talk to your system administrator to get them to enable these features for the accounts/files you need access to.
0
 
LVL 12

Author Comment

by:asidu
ID: 21278486
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.
0
 
LVL 12

Author Comment

by:asidu
ID: 21279476
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.

0
 
LVL 12

Author Comment

by:asidu
ID: 21280470
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.

0
 

Expert Comment

by:ashwin197816
ID: 21693811
what is you UPDATE query?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question