sql-metadata-plugin

Execute SQL to return result set metadata easily.

License

License

Categories

Categories

Data
GroupId

GroupId

io.github.pleuvoir
ArtifactId

ArtifactId

sql-metadata-plugin
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

sql-metadata-plugin
Execute SQL to return result set metadata easily.
Project URL

Project URL

https://github.com/pleuvoir/sql-metadata-plugin
Source Code Management

Source Code Management

https://github.com/pleuvoir/sql-metadata-plugin

Download sql-metadata-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.pleuvoir/sql-metadata-plugin/ -->
<dependency>
    <groupId>io.github.pleuvoir</groupId>
    <artifactId>sql-metadata-plugin</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.pleuvoir/sql-metadata-plugin/
implementation 'io.github.pleuvoir:sql-metadata-plugin:1.0.3'
// https://jarcasting.com/artifacts/io.github.pleuvoir/sql-metadata-plugin/
implementation ("io.github.pleuvoir:sql-metadata-plugin:1.0.3")
'io.github.pleuvoir:sql-metadata-plugin:jar:1.0.3'
<dependency org="io.github.pleuvoir" name="sql-metadata-plugin" rev="1.0.3">
  <artifact name="sql-metadata-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.pleuvoir', module='sql-metadata-plugin', version='1.0.3')
)
libraryDependencies += "io.github.pleuvoir" % "sql-metadata-plugin" % "1.0.3"
[io.github.pleuvoir/sql-metadata-plugin "1.0.3"]

Dependencies

compile (4)

Group / Artifact Type Version
io.github.pleuvoir : plugin-base jar 1.0.0
org.freemarker : freemarker jar 2.3.23
com.alibaba : druid jar 1.1.10
org.springframework : spring-context Optional jar 5.0.6.RELEASE

test (2)

Group / Artifact Type Version
org.springframework : spring-test jar 5.0.6.RELEASE
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

sql-metadata-plugin

Execute SQL to return result-set metadata easily. It also provide template engine support for code-generator.

HitCount GitHub issues License Maven Central Download

Usage

import dependency

<dependency>
	<groupId>io.github.pleuvoir</groupId>
	<artifactId>sql-metadata-plugin</artifactId>
	<version>${latest.version}</version>
</dependency>

register in spring container

<bean class="io.github.pleuvoir.sql.MetaDataConfiguration">
	<property name="ftlLocation" value="classpath:ftl" />

	<!-- if you use dataSourceConfig, Be careful of database driver -->
	<property name="dataSourceConfig">
		<bean class="io.github.pleuvoir.sql.bean.DataSourceConfig">
			<property name="driverClass" value="oracle.jdbc.OracleDriver" />
			<property name="url" value="jdbc:oracle:thin:@192.168.100.8:1521:cacplat" />
			<property name="username" value="auction_test" />
			<property name="password" value="auction_test" />
		</bean>
	</property>
</bean>

junit test

@Autowired
private DBScriptRunner dBScriptRunner;

@Test
public void contextTest() throws FileNotFoundException, IOException, TemplateException {

	// 1. get metaData
	MetaData metaData = dBScriptRunner.excute("select * from pub_param");

	String entityName = "pubParamPO";
	
	// 2. convert to dataModel
	DataModel dataModel = metaData.asDataModel().addData("entityName", entityName);

	System.out.println(dataModel.toJSON());
	
	// 3. write file ..
	dataModel.write("po.ftl", "D:\\" + entityName + ".java");
}

you can realize your TypeHandlerFactory to support more database type. look like this:

dBScriptRunner.setTypeHandlerFactory(new MyTypeHandlerFactory());
dBScriptRunner.excute("select * from pub_param", "org.h2.Driver");

LICENSE

Apache License

Versions

Version
1.0.3
1.0.2
1.0.1
1.0.0