asidu
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.UniJD BCDriver") .newInstan ce();
con=DriverManager.getConne ction("jdb c:ibm-u2:/ /<ip addr>//<database>","uname" ,"pwd");
stmt=con.createStatement() ;
ResultSet rs=stmt.executeQuery("sele ct @ID from TABLE");
while(rs.next())
System.out.println("Value= "+rs.getSt ring(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?
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.
con=DriverManager.getConne
stmt=con.createStatement()
ResultSet rs=stmt.executeQuery("sele
while(rs.next())
System.out.println("Value=
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?
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 ?
can you do it ?
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
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.UniJDBCMsg Factory.cr eateExcept ion(UniJDB CMsgFactor y.java:89)
at com.ibm.u2.jdbc.UniJDBCExc eptionSupp ort.addExc eption(Uni JDBCExcept ionSupport .java:87)
at com.ibm.u2.jdbc.UniJDBCPro tocolU2Imp l.addServe rError(Uni JDBCProtoc olU2Impl.j ava:2519)
at com.ibm.u2.jdbc.UniJDBCPro tocolU2Imp l.associat eServerCur sor(UniJDB CProtocolU 2Impl.java :1479)
at com.ibm.u2.jdbc.UniJDBCPro tocolU2Imp l.associat eCursor(Un iJDBCProto colU2Impl. java:1524)
at com.ibm.u2.jdbc.UniJDBCPro tocolU2Imp l.prepare( UniJDBCPro tocolU2Imp l.java:170 5)
at com.ibm.u2.jdbc.UniJDBCPro tocolU2Imp l.doExecut eAll(UniJD BCProtocol U2Impl.jav a:2069)
at com.ibm.u2.jdbc.UniJDBCPro tocolU2Imp l.executeS tatementQu ery(UniJDB CProtocolU 2Impl.java :563)
at com.ibm.u2.jdbc.UniJDBCSta tementImpl .executeQu ery(UniJDB CStatement Impl.java: 208)
at jdbcsample.testQuery(jdbcs ample.java :86)
at jdbcsample.main(jdbcsample .java:52)
Any help on this is much appreciated.
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.UniJDBCMsg
at com.ibm.u2.jdbc.UniJDBCExc
at com.ibm.u2.jdbc.UniJDBCPro
at com.ibm.u2.jdbc.UniJDBCPro
at com.ibm.u2.jdbc.UniJDBCPro
at com.ibm.u2.jdbc.UniJDBCPro
at com.ibm.u2.jdbc.UniJDBCPro
at com.ibm.u2.jdbc.UniJDBCPro
at com.ibm.u2.jdbc.UniJDBCSta
at jdbcsample.testQuery(jdbcs
at jdbcsample.main(jdbcsample
Any help on this is much appreciated.
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.
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.
what is you UPDATE query?
can you connect using those username and password from the db2 command line ?