Connection string: User ID and Password
When connecting using the JDBC driver, the User ID and Password in the DataSourceIPCustomProperties in the
oadm.ini file must have valid values (see
Updating the JDBC Service Driver to support custom connection property prefixes).
The User and Password used in the connection string setup in your Java code can have any values: these values are not used, but they must be set. For example, to test that you can read case data, reference the PHjc.jar, and create a Java application as follows.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
publicclassJDBCTest{
publicstaticvoidmain (String args[]) throws SQLException, ClassNotFoundException {
Class.forName("com.spss.datacollection.jdbc.openaccess.OpenAccessDriver");
String conStr = "jdbc:paswdatacollection://localhost:19999;CustomProperties=(Data Source=;Location=;Initial Catalog='C:\\CATITEST1.mdd';);User=JY-UI\\Administrator;Password=xxxxx;";
Connection conn = DriverManager.getConnection(conStr);
Statement sta = conn.createStatement();
String Sql = "select * from vdata";
ResultSet rs = sta.executeQuery(Sql);
while(rs.next()) {
System.out.println(rs.getString("Respondent.Serial"));
}
System.out.println("Finish!");
}
}
The connection string in the code can also be set to include both the User (not used) and the User Id (used) to override the oadm.ini values. For example:
String conStr = "jdbc:paswdatacollection://localhost:19999;CustomProperties=(Data Source=;Location=;Initial Catalog='C:\\CATITEST1.mdd';User ID=JY-UI\\Administrator;Password=Pass1234);User=sa;Password=abc;";
See also