GithubHelp home page GithubHelp logo

doytsujin / database-metadata-bind Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jinahya/database-metadata-bind

0.0 2.0 0.0 883 KB

A library for binding information from java.sql.DatabaseMetadata

License: Apache License 2.0

Java 100.00%

database-metadata-bind's Introduction

database-metadata-bind

Build Status Dependency Status Maven Central Javadocs Codacy Badge

A library binding various information from DatabaseMetaData.

Usage

API Binding

// prepare jdbc information
final Connection connection = connect();
final DatabaseMetaData metadata = connection.getMetaData();

// create context, and add suppressions if required
final MetadataContext context = new MetadataContext(metadata);
context.suppress("schema/functions", "table/pseudoColumns");

// bind various informations
final List<Catalog> catalogs = context.getCatalogs();
final List<Schema> schemas = context.getSchemas("", null);
final List<Tables> tables = context.getTables(null, null, null); // list all tables
final List<PrimaryKey> primaryKeys
    = context.getPrimaryKeys("PUBLIC", "SYSTEM_LOBS", "BLOCKS");

XML Binding

Almost all classes are annotated with @XmlRootElement.

final UDT udt;
final JAXBContext context = JAXBContext.newInstance(UDT.class);
final Marshaller marshaller = context.createMarshaller();
marshaller.mashal(udt, ...);

Testing

Memory

Test cases for in-memory databases such as Derby, H2, HSQLDB, SQLite are prepared.

Embedded (Experimental)

Tests against predefined embeddable databases.

$ mvn -Pembedded-<profile> \
      -Dserver=<server>
      -Dclient=<client> \
      -Dpaths="of/some,other/others,..." \
      -Dtest=<test> \
      test
$ cat target/embedded.<server>.xml

Properties

name value notes
server version of target database server see below
client version of target jdbc client see below
paths comma-separated suppression paths optional

Servers, Clients and Tests

database profile server is the version of client is the version of test
MariaDB mariadb ch.vorburger.mariaDB4j:mariaDB4j org.mariadb.jdbc:mariadb-java-client EmbeddedMariadbTest
PostgreSQL postgresql ru.yandex.qatools.embed:postgresql-embedded org.postgresql:postgresql EmbeddedPostgresqlTest

External

Tests against existing external databases.

$ mvn -Pexternal-<server> \
      -Dclient="x.y.z" \
      -Durl="jdbc:...://..." \
      -Duser="some" \
      -Dpassword="some" \
      -Dpaths="of/some,other/others,..." \
      -Dtest=ExternalTest \
      test
$ cat target/external.xml

Properties

name value notes
server target database server see below
client version of target jdbc client see below
url connection url The first argument of DriverManager#getConnection
user username The second argument of DriverManager#getConnection
password password The third argument of DriverManager#getConnection
paths comma-separated suppression paths optional

Servers, Clients and URLs

database server client is the version of url prefix
MySQL mysql mysql:mysql-connector-java jdbc:mysql://...
MariaDB mariadb org.mariadb.jdbc:mariadb-java-client jdbc:mariadb://...
PostgreSQL postgresql org.postgresql:postgresql jdbc:postgresql://...
SQL Server sqlserver com.microsoft.sqlserver:mssql-jdbc jdbc:sqlserver://...
Oracle oracle com.oracle.jdbc:ojdbc8 jdbc:oracle:thin://...

Domate via Paypal

database-metadata-bind's People

Contributors

bilak avatar jinahya avatar onacit avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.