DB2 Declaration
To define the connection and configuration of DB2 for Jopaz there are two options.
Option 1
In the first option, the parameters are set directly in the RUNOPT file:
jopaz.jdbc.url=jdbc:db2://db2_host_or_IP:DB2_port/database
jopaz.jdbc.options=user=DB2_user,password=DB2_password
jopaz.jdbc.driver=com.ibm.db2.jcc.DB2Driver
jopaz.jdbc.auto_connect=1
jopaz.jdbc.dateformat=Date_format_e.g._dd.MM.yyyy
jopaz.jdbc.kept_spaces=2
jopaz.jdbc.options=fixedString=false
where db2_host_or_IP is your IP or host number, DB2_port is the number of the DB2 port, database is the name of your database, and DB2_user and DB2_password are your personalized username and password.
Option 2
The second option uses a separate data source class:
jopaz.jdbc.datasource=DataSource
jopaz.jdbc.driver=com.ibm.db2.jcc.DB2Driver
jopaz.jdbc.auto_connect=1
jopaz.jdbc.dateformat=Date_format_e.g._dd.MM.yyyy
jopaz.jdbc.kept_spaces=2
jopaz.jdbc.options=fixedString=false
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.jopaz.rts.MyDataSource;
public class DataSource implements MyDataSource {
private static final String URL = "jdbc:db2://DB2_host_or_ip:DB2_port/Database";
private static final String USER = "DB2_user";
private static final String PASSWORD = "DB2_password";
@Override
public Connection connect(String db, String user, String password) throws SQLException {
String connUser = user != null && !user.trim().equals("") ? user : USER;
String connPassword = password != null && !password.trim().equals("")? password : PASSWORD;
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
} catch (ClassNotFoundException e) {
throw new SQLException(e);
}
return DriverManager.getConnection(URL, connUser, connPassword);
}
}
where Package_name is the name of the package you are using, db2_host_or_IP is your IP or host number, DB2_port is the number of the DB2 port, database is the name of your database, and DB2_user and DB2_password are your personalized username and password.