-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @Author : Robert Huang<[email protected]> * | ||
* @CreatedDate : 2023-03-07 00:03:27 * | ||
* @LastEditors : Robert Huang<[email protected]> * | ||
* @LastEditDate : 2023-10-19 10:46:00 * | ||
* @LastEditDate : 2023-10-19 14:47:59 * | ||
* @FilePath : src/main/java/com/da/crystal/report/CRJavaHelper.java * | ||
* @CopyRight : Dedienne Aerospace China ZhuHai * | ||
*********************************************************************************************************************/ | ||
|
@@ -103,6 +103,7 @@ public static void changeDataSource( | |
String password, | ||
String connectionURL, | ||
String driverName, | ||
String JNDI, | ||
String fileName, | ||
String filePath | ||
) { | ||
|
@@ -115,17 +116,21 @@ public static void changeDataSource( | |
// JNDI name for Crystal Report must start with 'jdbc/' | ||
// https://userapps.support.sap.com/sap/support/knowledge/en/1343290 | ||
|
||
newPropertyBag.put("Server Type", "JDBC (JNDI)"); | ||
newPropertyBag.put("Use JDBC", "true"); | ||
newPropertyBag.put("Trusted_Connection", "false"); | ||
newPropertyBag.put("Connection URL", connectionURL); | ||
newPropertyBag.put("Database Class Name", driverName); | ||
newPropertyBag.put("Database DLL", "crdb_jdbc.dll"); | ||
if (!JNDI.isBlank()) { | ||
newPropertyBag.put("Connection Name (Optional)", JNDI); | ||
} else { | ||
newPropertyBag.put("Server Type", "JDBC (JNDI)"); | ||
newPropertyBag.put("Use JDBC", "true"); | ||
newPropertyBag.put("Trusted_Connection", "false"); | ||
newPropertyBag.put("Connection URL", connectionURL); | ||
newPropertyBag.put("Database Class Name", driverName); | ||
newPropertyBag.put("Database DLL", "crdb_jdbc.dll"); | ||
} | ||
|
||
// If same jdbc info, just do login | ||
IConnectionInfo oldConnectionInfo = clientDoc.getDatabaseController().getConnectionInfos(null).get(0); | ||
PropertyBag oldPropertyBag = oldConnectionInfo.getAttributes(); | ||
if ( | ||
if (JNDI.isBlank() && | ||
oldPropertyBag.getStringValue("Server Type").equals("JDBC (JNDI)") && | ||
oldPropertyBag.getStringValue("Connection URL").equals(connectionURL) && | ||
oldPropertyBag.getStringValue("Database Class Name").equals(driverName) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @Author : Robert Huang<[email protected]> * | ||
* @CreatedDate : 2023-03-06 21:22:42 * | ||
* @LastEditors : Robert Huang<[email protected]> * | ||
* @LastEditDate : 2023-10-19 14:16:56 * | ||
* @LastEditDate : 2023-10-19 14:50:30 * | ||
* @FilePath : src/main/java/com/da/crystal/report/ReportController.java * | ||
* @CopyRight : Dedienne Aerospace China ZhuHai * | ||
*********************************************************************************************************************/ | ||
|
@@ -47,6 +47,9 @@ public class ReportController { | |
@Value("${rpt.datasource.password}") | ||
private String password; | ||
|
||
@Value("${rpt.datasource.JNDI}") | ||
private String JNDI; | ||
|
||
@GetMapping("/Report/*/*") | ||
public void handReportRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException { | ||
try { | ||
|
@@ -98,7 +101,7 @@ public void handReportRequest(HttpServletRequest req, HttpServletResponse resp) | |
|
||
// open report | ||
clientDoc = ReportClientDocument.openReport(file); | ||
|
||
// Check/Set report param | ||
List<String> reportParams = CRJavaHelper.getTopParams(clientDoc); | ||
for (String param : reportParams) { | ||
|
@@ -126,8 +129,17 @@ public void handReportRequest(HttpServletRequest req, HttpServletResponse resp) | |
clientDoc.setSummaryInfo(summaryInfo); | ||
|
||
// set Database connection | ||
CRJavaHelper.changeDataSource(clientDoc, username, password, url, driverClassName, report + ".rpt", reportsPath); | ||
|
||
CRJavaHelper.changeDataSource( | ||
clientDoc, | ||
username, | ||
password, | ||
url, | ||
driverClassName, | ||
JNDI, | ||
report + ".rpt", | ||
reportsPath | ||
); | ||
|
||
// export report | ||
switch (format) { | ||
case "pdf": | ||
|