Compare commits
15 Commits
release/10
...
persist/10
Author | SHA1 | Date |
---|---|---|
Icey.Zhang | c974449e23 | 4 years ago |
Lanlan | c21ebed9f4 | 4 years ago |
Okcean | ce7482718d | 4 years ago |
Okcean | 26e083a658 | 4 years ago |
Bruce.Deng | d1776fa526 | 4 years ago |
Leo.Tsai | ca629a1ff6 | 4 years ago |
Leo.Cai | 99ff96fea6 | 4 years ago |
Lanlan | e1f402023f | 5 years ago |
Lanlan | 5a3d9301af | 5 years ago |
susie | 34ec362f64 | 5 years ago |
Harrison | c81c49f7ad | 5 years ago |
Lanlan | 9a474478b3 | 5 years ago |
Lanlan | 10e88848e4 | 5 years ago |
Lanlan | d6274eea84 | 5 years ago |
Lanlan | de51123131 | 5 years ago |
11 changed files with 194 additions and 160 deletions
@ -0,0 +1,78 @@
|
||||
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(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue