Skip to content

Commit

Permalink
fix: 🐛fix compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
hks2002 committed Oct 19, 2023
1 parent 6831101 commit 6cbda68
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
16 changes: 16 additions & 0 deletions JNDI-SAMPLE.XML
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Copy it to tomcat/conf context.xml -->
<!-- Copy jar of driverClass/JNDIFactory to tomcat lib -->
<!-- If you want to change db pool factory, add this factory="com.zaxxer.hikari.HikariJNDIFactory" -->
<!-- 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 -->
<Resource name="jdbc/SageDB" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://server\instance;DatabaseName=dbname;trustServerCertificate=true"
username="user"
password="password"
maxTotal="4"
maxIdle="2"
initialSize="1"
removeAbandonedOnBorrow="true"
removeAbandonedOnMaintenance="true"
removeAbandonedTimeout="60" />
11 changes: 6 additions & 5 deletions src/main/java/com/da/crystal/report/CRJavaHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 *
*********************************************************************************************************************/
Expand Down Expand Up @@ -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
Expand All @@ -103,7 +104,7 @@ public static void changeDataSource(
String password,
String connectionURL,
String driverName,
String JNDI,
String jndiName,
String fileName,
String filePath
) {
Expand All @@ -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");
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/da/crystal/report/ReportController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:50:30 *
* @LastEditDate : 2023-10-19 16:46:17 *
* @FilePath : src/main/java/com/da/crystal/report/ReportController.java *
* @CopyRight : Dedienne Aerospace China ZhuHai *
*********************************************************************************************************************/
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -135,7 +135,7 @@ public void handReportRequest(HttpServletRequest req, HttpServletResponse resp)
password,
url,
driverClassName,
JNDI,
jndiName,
report + ".rpt",
reportsPath
);
Expand Down

0 comments on commit 6cbda68

Please sign in to comment.