From 2d925ee7af05d2a8eb2c8894ca9b4bfa2ed3df1c Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 4 Jan 2022 17:03:56 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-65380=20=E5=BC=95=E6=93=8EAPI>=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=A8=A1=E6=9D=BF=E8=87=B3=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BC=96=E8=AF=91=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/io/SaveReportToDatabase.java | 78 ------------------- 1 file changed, 78 deletions(-) delete mode 100644 src/main/java/com/fr/io/SaveReportToDatabase.java diff --git a/src/main/java/com/fr/io/SaveReportToDatabase.java b/src/main/java/com/fr/io/SaveReportToDatabase.java deleted file mode 100644 index 1608a48..0000000 --- a/src/main/java/com/fr/io/SaveReportToDatabase.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.fr.io; - -import com.fr.base.operator.common.CommonOperator; -import com.fr.chart.activator.ChartBaseActivator; -import com.fr.cluster.engine.activator.standalone.StandaloneModeActivator; -import com.fr.config.activator.BaseDBActivator; -import com.fr.config.activator.ConfigurationActivator; -import com.fr.env.operator.CommonOperatorImpl; -import com.fr.general.I18nResource; -import com.fr.health.activator.ModuleHealActivator; -import com.fr.module.Module; -import com.fr.module.tool.ActivatorToolBox; -import com.fr.report.ReportActivator; -import com.fr.report.RestrictionActivator; -import com.fr.report.module.ReportBaseActivator; -import com.fr.report.write.WriteActivator; -import com.fr.scheduler.SchedulerActivator; -import com.fr.store.StateServiceActivator; -import com.fr.workspace.simple.SimpleWork; - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; - -public class SaveReportToDatabase { - public static void main(String[] args) { - SaveReport(); - } - private static void SaveReport() { - try { - // 连接数据库 - String driver = "com.mysql.jdbc.Driver"; - String url = "jdbc:mysql://review.finedevelop.com:3306/susie"; - String user = "root"; - String pass = "ilovejava"; - Class.forName(driver); - Connection conn = DriverManager.getConnection(url, user, pass); - PreparedStatement presmt = conn - .prepareStatement("insert into report values(?,?)"); - // 读进需要保存入库的模板文件 - // 首先需要定义执行所在的环境,这样才能正确读取数据库信息 - // 定义报表运行环境,用于执行报表 - Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), - new ConfigurationActivator(), - new ResourceRepositoryActivator(), - new StandaloneModeActivator(), - new ModuleHealActivator(), - new StateServiceActivator(), - new ChartBaseActivator(), - new SchedulerActivator(), - new ReportBaseActivator(), - new RestrictionActivator(), - new ReportActivator(), - new WriteActivator()); - SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); - String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 - SimpleWork.checkIn(envpath); - I18nResource.getInstance(); - module.start(); - - File cptfile = new File("//doc//Primary//Parameter//Parameter.cpt"); - int lens = (int) cptfile.length(); - InputStream ins = new FileInputStream(cptfile); - // 将模板保存入库 - presmt.setString(1, "Parameter.cpt"); // 第一个字段存放模板相对路径 - presmt.setBinaryStream(2, ins, lens); // 第二个字段存放模板文件的二进制流 - presmt.execute(); - conn.commit(); - presmt.close(); - conn.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } -} \ No newline at end of file