I had this error when were running Crystal reports after we switched from using Oracle to PostgreSQL. Below is the original code.
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(<reportName.rpt>, 0);
Tables tables = databaseController.getDatabase().getTables();
for (int i = 0; i < tables.size(); i++) {
ITable table = tables.getTable(i);
IConnectionInfo connectionInfo = table.getConnectionInfo();
PropertyBag propertyBag = new PropertyBag();
propertyBag.put("URI", "!oracle.jdbc.OracleDriver!jdbc:oracle:thin:{userid}/{password}@" + host + ":" + port + ":" + databaseName);
//propertyBag.put("Use JDBC", "true");
propertyBag.put("Database DLL", "crdb_jdbc.dll");
connectionInfo.setAttributes(propertyBag);
connectionInfo.setUserName(<database userName>);
connectionInfo.setPassword(<database password>);
table.setConnectionInfo(connectionInfo);
//Throws error here.It somehow does not use the username and password
//set in the connectionInfo to logon. Instead, it uses the application login user id.
databaseController.setTableLocation(table, tables.getTable(i));
}
To fix this, use the code below to replace the code above in blue background.
StringBuilder url = new StringBuilder();
url.append("jdbc:postgresql://").append(host).append(":")
.append(port).append("/").append(databaseName);
StringBuilder uri = new StringBuilder();
uri.append("!org.postgresql.Driver!").append(url.toString())
.append("!user={userid}!password={password}");
propertyBag.put("JDBC Connection String", uri.toString());
propertyBag.put("Connection URL", url.toString());
propertyBag.put("Database Classname", "org.postgresql.Driver");
propertyBag.put("Database", databaseName);
propertyBag.put("Database Type", "JDBC (JNDI)");
propertyBag.put("JDBC Connection", "True");
propertyBag.put("Server", "");
propertyBag.put("User ID", userName);
propertyBag.put("Password", password);
----------------------------------------------------------------------------------------
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(<reportName.rpt>, 0);
Tables tables = databaseController.getDatabase().getTables();
for (int i = 0; i < tables.size(); i++) {
ITable table = tables.getTable(i);
IConnectionInfo connectionInfo = table.getConnectionInfo();
PropertyBag propertyBag = new PropertyBag();
propertyBag.put("URI", "!oracle.jdbc.OracleDriver!jdbc:oracle:thin:{userid}/{password}@" + host + ":" + port + ":" + databaseName);
//propertyBag.put("Use JDBC", "true");
propertyBag.put("Database DLL", "crdb_jdbc.dll");
connectionInfo.setAttributes(propertyBag);
connectionInfo.setUserName(<database userName>);
connectionInfo.setPassword(<database password>);
table.setConnectionInfo(connectionInfo);
//Throws error here.It somehow does not use the username and password
//set in the connectionInfo to logon. Instead, it uses the application login user id.
databaseController.setTableLocation(table, tables.getTable(i));
}
To fix this, use the code below to replace the code above in blue background.
StringBuilder url = new StringBuilder();
url.append("jdbc:postgresql://").append(host).append(":")
.append(port).append("/").append(databaseName);
StringBuilder uri = new StringBuilder();
uri.append("!org.postgresql.Driver!").append(url.toString())
.append("!user={userid}!password={password}");
propertyBag.put("JDBC Connection String", uri.toString());
propertyBag.put("Connection URL", url.toString());
propertyBag.put("Database Classname", "org.postgresql.Driver");
propertyBag.put("Database", databaseName);
propertyBag.put("Database Type", "JDBC (JNDI)");
propertyBag.put("JDBC Connection", "True");
propertyBag.put("Server", "");
propertyBag.put("User ID", userName);
propertyBag.put("Password", password);
----------------------------------------------------------------------------------------
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.
No comments:
Post a Comment