From bf88811291be229d291aaf5e564b5ebcaae4a890 Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 28 Dec 2021 17:40:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-65118=20REPORT-64392=20=E8=BF=99?= =?UTF-8?q?=E4=B8=AA=E4=BB=BB=E5=8A=A1=E5=86=8D=E7=9C=8B=E4=B8=8B=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E7=AB=AF=E6=8A=A5=E9=94=99=E4=BE=A7=E6=9C=89=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=83=BD=E4=BC=98=E5=8C=96=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/demo/NewReadFrmFromDatabase.java | 18 ++++++++++-------- .../java/com/fr/demo/ReadFromDatabase.java | 4 +++- .../java/com/fr/demo/ReadfrmFromDatabase.java | 8 +++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/fr/demo/NewReadFrmFromDatabase.java b/src/main/java/com/fr/demo/NewReadFrmFromDatabase.java index 8186fe9..8350a6b 100644 --- a/src/main/java/com/fr/demo/NewReadFrmFromDatabase.java +++ b/src/main/java/com/fr/demo/NewReadFrmFromDatabase.java @@ -1,16 +1,18 @@ package com.fr.demo; import com.fr.data.core.db.DBUtils; -import com.fr.web.weblet.DBFormlet; import com.fr.form.main.Form; -import java.sql.SQLException; -import javax.servlet.http.HttpServletRequest; import com.fr.log.FineLoggerFactory; +import com.fr.web.session.SessionLocalManager; +import com.fr.web.weblet.DBFormlet; + +import javax.servlet.http.HttpServletRequest; import java.io.InputStream; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Statement; import java.util.Map; @@ -26,7 +28,7 @@ public class NewReadFrmFromDatabase extends DBFormlet { @Override public Form createForm(String reportName) { - Form form = new Form(); + Form form = null; Connection connection = null; try { connection = getConnection(); @@ -43,20 +45,20 @@ public class NewReadFrmFromDatabase extends DBFormlet { return form; } } catch (Exception e) { - e.printStackTrace(); + throw SessionLocalManager.createLogPackedException(e); }finally { DBUtils.closeConnection(connection); } - return null; + return form; } private static Connection getConnection() throws ClassNotFoundException, SQLException { // 定义数据连接(根据你实际数据库信息进行修改) String driver = "com.mysql.jdbc.Driver"; - String url = "jdbc:mysql://localhost:3306/test"; + String url = "jdbc:mysql://localhost:3306/frtest"; String user = "root"; - String pass = "123456"; + String pass = "root"; Class.forName(driver); Connection conn = DriverManager.getConnection(url, user, pass); return conn; diff --git a/src/main/java/com/fr/demo/ReadFromDatabase.java b/src/main/java/com/fr/demo/ReadFromDatabase.java index c5ad4eb..f78c426 100644 --- a/src/main/java/com/fr/demo/ReadFromDatabase.java +++ b/src/main/java/com/fr/demo/ReadFromDatabase.java @@ -5,6 +5,8 @@ import com.fr.main.impl.WorkBook; import com.fr.web.core.Reportlet; import com.fr.web.request.ReportletRequest; import com.fr.log.FineLoggerFactory; +import com.fr.web.session.SessionLocalManager; + import java.io.InputStream; import java.sql.Blob; import java.sql.Connection; @@ -40,7 +42,7 @@ public class ReadFromDatabase extends Reportlet { workbook.readStream(ins); } } catch (Exception e) { - e.printStackTrace(); + throw SessionLocalManager.createLogPackedException(e); } return workbook; } diff --git a/src/main/java/com/fr/demo/ReadfrmFromDatabase.java b/src/main/java/com/fr/demo/ReadfrmFromDatabase.java index 601fca0..143ea1f 100644 --- a/src/main/java/com/fr/demo/ReadfrmFromDatabase.java +++ b/src/main/java/com/fr/demo/ReadfrmFromDatabase.java @@ -1,10 +1,12 @@ package com.fr.demo; +import com.fr.form.main.Form; import com.fr.io.utils.ResourceIOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.web.session.SessionLocalManager; import com.fr.web.weblet.Formlet; -import com.fr.form.main.Form; + import javax.servlet.http.HttpServletRequest; -import com.fr.log.FineLoggerFactory; import java.io.InputStream; import java.sql.Blob; import java.sql.Connection; @@ -42,7 +44,7 @@ public class ReadfrmFromDatabase extends Formlet { form.readStream(ins); } } catch (Exception e) { - e.printStackTrace(); + throw SessionLocalManager.createLogPackedException(e); } System.out.println(ResourceIOUtils.getRealPath("assets")); return form; From e79e8f895ea2dd09ce23ee3e202456770743b1a5 Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 28 Dec 2021 17:43:21 +0800 Subject: [PATCH 2/2] 1 --- src/main/java/com/fr/demo/NewReadFrmFromDatabase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fr/demo/NewReadFrmFromDatabase.java b/src/main/java/com/fr/demo/NewReadFrmFromDatabase.java index 8350a6b..0895cc7 100644 --- a/src/main/java/com/fr/demo/NewReadFrmFromDatabase.java +++ b/src/main/java/com/fr/demo/NewReadFrmFromDatabase.java @@ -56,9 +56,9 @@ public class NewReadFrmFromDatabase extends DBFormlet { private static Connection getConnection() throws ClassNotFoundException, SQLException { // 定义数据连接(根据你实际数据库信息进行修改) String driver = "com.mysql.jdbc.Driver"; - String url = "jdbc:mysql://localhost:3306/frtest"; + String url = "jdbc:mysql://localhost:3306/test"; String user = "root"; - String pass = "root"; + String pass = "123456"; Class.forName(driver); Connection conn = DriverManager.getConnection(url, user, pass); return conn;