本文整理汇总了Java中org.dbunit.dataset.xml.FlatDtdDataSet类的典型用法代码示例。如果您正苦于以下问题:Java FlatDtdDataSet类的具体用法?Java FlatDtdDataSet怎么用?Java FlatDtdDataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlatDtdDataSet类属于org.dbunit.dataset.xml包,在下文中一共展示了FlatDtdDataSet类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDtdSchema
import org.dbunit.dataset.xml.FlatDtdDataSet; //导入依赖的package包/类
private Reader getDtdSchema(boolean resetDtdSchema) throws Exception {
if (resetDtdSchema || dtdSchema == null) {
Connection c = getEmireCfg().getConnection();
try {
IDatabaseConnection dc = createProgresConnection(c);
StringWriter sw = new StringWriter();
FlatDtdDataSet.write(dc.createDataSet(), sw);
dtdSchema = sw.toString();
// System.out.println(dtdSchema);
} finally {
c.close();
}
}
return new StringReader(dtdSchema);
}
示例2: run
import org.dbunit.dataset.xml.FlatDtdDataSet; //导入依赖的package包/类
@Scheduled(cron = "0 0 3 * * *")
public void run() throws SQLException, DatabaseUnitException, IOException {
if (enable) {
log.info("begin backup database");
String bak = root + "/" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
ITableFilter filter = new DatabaseSequenceFilter(conn);
IDataSet dataSet = new FilteredDataSet(filter, conn.createDataSet());
//IDataSet dataSet = conn.createDataSet();
FlatXmlDataSet.write(dataSet, new FileOutputStream(bak + ".xml"));
FlatDtdDataSet.write(dataSet, new FileOutputStream(bak + ".dtd"));
log.info("end backup database");
}
}
示例3: main
import org.dbunit.dataset.xml.FlatDtdDataSet; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
DataSource dataSource = new DataSourceFactoryBean().getDataSource();
File file = new File("src/main/resources/mycollab.dtd");
IDatabaseConnection connection = new DatabaseDataSourceConnection(dataSource);
connection.getConfig().setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, true);
// write DTD file
FlatDtdDataSet.write(connection.createDataSet(), new FileOutputStream(file));
}
示例4: main
import org.dbunit.dataset.xml.FlatDtdDataSet; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Config config = new Config();
Class.forName(config.getDbDriver());
Connection jdbcConnection = DriverManager.getConnection(config.getDbUrl(), config.getDbUser(), config.getDbPass());
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection, "public");
// dtd
FlatDtdDataSet.write(connection.createDataSet(), new FileOutputStream("src/test/java/it/pronetics/acl/conf/dbunit/database-schema.dtd"));
// export
IDataSet fullDataSet = connection.createDataSet();
FlatXmlDataSet.write(fullDataSet, new FileOutputStream("src/test/java/opennms/opennms/acl/conf/dbunit/full.xml"));
}
示例5: writeDtd
import org.dbunit.dataset.xml.FlatDtdDataSet; //导入依赖的package包/类
protected void writeDtd(IDatabaseConnection dbunitConnection,String tableName) throws IOException,
DataSetException, SQLException {
File placeholder = new File(DatabaseCapable.class
.getResource("/expected/.dbunit-comparison-files")
.getFile());
File dtdFile = new File(placeholder.getParentFile()
.getPath()
+ System.getProperty("file.separator")
+ tableName + ".dtd");
FlatDtdDataSet.write(dbunitConnection.createDataSet(new String[] { tableName } ), new FileOutputStream(dtdFile));
}
示例6: main
import org.dbunit.dataset.xml.FlatDtdDataSet; //导入依赖的package包/类
/**
* Cambiar los datos de la conexión de acuerdo a la base de datos que se quiera usar como muestra
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception
{
String url = JOptionPane.showInputDialog("Escriba la URL de MySQL incluyendo driver");
String user = JOptionPane.showInputDialog("Escriba el nombre de usuario de la BD");
String pass = JOptionPane.showInputDialog("Escriba la clave de la BD");
String dir = "test/src/omoikane/repository/sampleData.xml";
Class driverClass = Class.forName("com.mysql.jdbc.Driver");
Connection jdbcConnection = DriverManager.getConnection(
url, user, pass);
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
// Datos seleccionados considerando la base de datos de Omoikane 1.3.3 -> 1.4.0 alpha
QueryDataSet partialDataSet = new QueryDataSet(connection);
partialDataSet.addTable("articulos" , "SELECT * FROM articulos ORDER BY id_articulo DESC LIMIT 200");
partialDataSet.addTable("base_para_precios", "SELECT * FROM base_para_precios ORDER BY id_articulo DESC LIMIT 200");
partialDataSet.addTable("ventas" , "SELECT * FROM ventas ORDER BY id_venta DESC LIMIT 50");
partialDataSet.addTable("ventas_detalles" , "SELECT vd.* FROM ventas_detalles vd JOIN (SELECT id_venta FROM ventas ORDER BY id_venta DESC LIMIT 50) v ON (vd.id_venta = v.id_venta)");
partialDataSet.addTable("cajas" , "SELECT * FROM cajas");
FlatXmlDataSet.write(partialDataSet, new FileOutputStream(dir));
FlatDtdDataSet.write(connection.createDataSet(), new FileOutputStream("test/src/omoikane/repository/sampleBDSchema.dtd"));
System.out.println("{}");
JOptionPane.showMessageDialog(null, "Proceso completado. BD importada en "+dir);
}
示例7: extractXmlSchema
import org.dbunit.dataset.xml.FlatDtdDataSet; //导入依赖的package包/类
/**
* Extracts the XML DTD from the database schema.
*
* @throws Exception
* If any errors occur connecting to the database, reading the
* database contents, or writing the DTD file.
*/
public static void extractXmlSchema() throws Exception {
IDatabaseConnection connection = getDatabaseConnection();
FlatDtdDataSet.write(connection.createDataSet(), new FileOutputStream("src/test/resources/dbunit/export.dtd"));
}