diff --git a/JNDI-SAMPLE.XML b/JNDI-SAMPLE.XML new file mode 100644 index 0000000..9a456ba --- /dev/null +++ b/JNDI-SAMPLE.XML @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/src/main/java/com/da/crystal/report/CRJavaHelper.java b/src/main/java/com/da/crystal/report/CRJavaHelper.java index 7f15450..ac87046 100644 --- a/src/main/java/com/da/crystal/report/CRJavaHelper.java +++ b/src/main/java/com/da/crystal/report/CRJavaHelper.java @@ -2,7 +2,7 @@ * @Author : Robert Huang<56649783@qq.com> * * @CreatedDate : 2023-03-07 00:03:27 * * @LastEditors : Robert Huang<56649783@qq.com> * - * @LastEditDate : 2023-10-19 14:47:59 * + * @LastEditDate : 2023-10-19 16:38:07 * * @FilePath : src/main/java/com/da/crystal/report/CRJavaHelper.java * * @CopyRight : Dedienne Aerospace China ZhuHai * *********************************************************************************************************************/ @@ -91,6 +91,7 @@ public static void logonDataSource(ReportClientDocument clientDoc, String userna * @param password The DB logon password * @param connectionURL The connection URL * @param driverName The driver Name + * @param jndiName The JNDI Name * @param fileName The file name * @param filePath The file path * // How to use a JNDI data source with the Crystal Reports Java SDK on Tomcat https://userapps.support.sap.com/sap/support/knowledge/en/1343290 @@ -103,7 +104,7 @@ public static void changeDataSource( String password, String connectionURL, String driverName, - String JNDI, + String jndiName, String fileName, String filePath ) { @@ -116,8 +117,8 @@ public static void changeDataSource( // JNDI name for Crystal Report must start with 'jdbc/' // https://userapps.support.sap.com/sap/support/knowledge/en/1343290 - if (!JNDI.isBlank()) { - newPropertyBag.put("Connection Name (Optional)", JNDI); + if (!jndiName.isBlank()) { + newPropertyBag.put("Connection Name (Optional)", jndiName); } else { newPropertyBag.put("Server Type", "JDBC (JNDI)"); newPropertyBag.put("Use JDBC", "true"); @@ -130,7 +131,7 @@ public static void changeDataSource( // If same jdbc info, just do login IConnectionInfo oldConnectionInfo = clientDoc.getDatabaseController().getConnectionInfos(null).get(0); PropertyBag oldPropertyBag = oldConnectionInfo.getAttributes(); - if (JNDI.isBlank() && + if (jndiName.isBlank() && oldPropertyBag.getStringValue("Server Type").equals("JDBC (JNDI)") && oldPropertyBag.getStringValue("Connection URL").equals(connectionURL) && oldPropertyBag.getStringValue("Database Class Name").equals(driverName) diff --git a/src/main/java/com/da/crystal/report/ReportController.java b/src/main/java/com/da/crystal/report/ReportController.java index 7eae5e5..81e9811 100644 --- a/src/main/java/com/da/crystal/report/ReportController.java +++ b/src/main/java/com/da/crystal/report/ReportController.java @@ -2,7 +2,7 @@ * @Author : Robert Huang<56649783@qq.com> * * @CreatedDate : 2023-03-06 21:22:42 * * @LastEditors : Robert Huang<56649783@qq.com> * - * @LastEditDate : 2023-10-19 14:50:30 * + * @LastEditDate : 2023-10-19 16:46:17 * * @FilePath : src/main/java/com/da/crystal/report/ReportController.java * * @CopyRight : Dedienne Aerospace China ZhuHai * *********************************************************************************************************************/ @@ -47,8 +47,8 @@ public class ReportController { @Value("${rpt.datasource.password}") private String password; - @Value("${rpt.datasource.JNDI}") - private String JNDI; + @Value("${rpt.datasource.jndiName}") + private String jndiName; @GetMapping("/Report/*/*") public void handReportRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException { @@ -135,7 +135,7 @@ public void handReportRequest(HttpServletRequest req, HttpServletResponse resp) password, url, driverClassName, - JNDI, + jndiName, report + ".rpt", reportsPath );