IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Getting Error while trying to establish connection via JDBC


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
arnab809

New User


Joined: 17 Mar 2023
Posts: 2
Location: India

PostPosted: Fri Mar 17, 2023 10:15 pm
Reply with quote

import java.sql.*;
public class TestJDBCConn {       
public static void main(String args[]) 
throws ClassNotFoundException      {         
String user,password,url;         
Connection con = null;        
  try {              String driverClassName = "com.ibm.db2.jcc.DB2Driver";            System.out.println ();            System.out.println ( "Loading DB2 JDBC Driver: " + driverClassName );            Class.forName ( driverClassName );  
          System.out.println ( "  successful driver load, version " +                com.ibm.db2.jcc.DB2Version.getVersion() );  
              // Establish Connection; if type-2 z/OS this will trigger load of DLL            
url = "jdbc:db2os390:";           
 user = null;            
password = null;          
  con = DriverManager.getConnection(url,user,password);  
            System.out.println("Connection created");              con.close();            
  System.out.println("Connection closed");         
     }    
          catch (Exception e) 
{             
System.out.println(e.toString());       
   }    
  }  




While running this code
getting this error :


Failure in loading native library db2jcct2zos4_64, java.lang.UnsatisfiedLinkError: db2jcct2zos4_64
(Not found in java.library.path):  ERRORCODE=-4472, SQLSTATE=null  


value of system environment variable $LIBPATH is /usr/lpp/db2c10/jdbc/lib:/lib:/usr/lib:/usr/lpp/IBM/zoautil/lib:/rsusr/ported/li
b:/rsusr/ported/lib/perl5/5.24.0/os390/CORE:.   


We are using IBM ZD&T machine and all the software got installed during installation. We have not installed any software or configured anything of our own. 



on executing System.out.println(System.getProperty("java.library.path")); we are getting following list of paths:



/Z24D/usr/lpp/java/J8.0_64/lib/s390x/compressedrefs:/Z24D/usr/lpp/java/J8.0_64/l
ib/s390x:/Z24D/usr/lpp/java/J8.0_64/lib/s390x/compressedrefs:/Z24D/usr/lpp/java/
J8.0_64/lib/s390x/j9vm:/Z24D/usr/lpp/java/J8.0_64/lib/s390x:/Z24D/usr/lpp/java/J
8.0_64/../lib/s390x:/Z24D/usr/lpp/java/J8.0_64/lib/icc:/Z24D/usr/lpp/java/J8.0_6
4/lib/s390x:/usr/lpp/db2c10/jdbc/lib:/lib:/usr/lib:/usr/lpp/IBM/zoautil/lib:/rsu
sr/ported/lib:/rsusr/ported/lib/perl5/5.24.0/os390/CORE:.                       

     
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri Mar 17, 2023 11:12 pm
Reply with quote

Just spitballing here, it looks like this library is not found db2jcct2zos4_64 in the path libraries.

I would do a OMVS find command to see where that library is, and then add that library to the path.

TSO OMVS
Code:
$ find / -name db2jcct2zos4_64 -depth
Back to top
View user's profile Send private message
arnab809

New User


Joined: 17 Mar 2023
Posts: 2
Location: India

PostPosted: Sun Mar 19, 2023 9:15 am
Reply with quote

No result from this command. Seems its not present. Is ther any other way to connect the db2 through Java code
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Mon Mar 20, 2023 4:59 pm
Reply with quote

Try type4 connection.
www.ibm.com/support/pages/failure-loading-native-library-db2jcct2-unsatisfiedlinkerror-errorcode-4472
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Zunit Test case editor error Testing & Performance 4
Search our Forums:

Back to Top