Connection string
When connecting using the JDBC driver, you must set the User ID and Password parameters in the
DataSourceIPCustomProperties section in the
oadm.ini file: see
Updating the JDBC Service Driver to support custom connection property prefixes.
The User and Password used in the connection string setup in the Java code can be set with any value; they must be set, but the values are not used. 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 values that are in the oadm.ini file. 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;";