jdbc

simple jdbc classes implementation

Лицензия

Лицензия

Категории

Категории

Ant Компиляция и сборка
Группа

Группа

com.github.antonsjava
Идентификатор

Идентификатор

jdbc
Последняя версия

Последняя версия

1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

jdbc
simple jdbc classes implementation
Ссылка на сайт

Ссылка на сайт

https://github.com/antonsjava/jdbc
Система контроля версий

Система контроля версий

https://github.com/antonsjava/jdbc

Скачать jdbc

Имя Файла Размер
jdbc-1.1.pom
jdbc-1.1.jar 16 KB
jdbc-1.1-sources.jar 13 KB
jdbc-1.1-javadoc.jar 470 KB
Обзор

Как подключить последнюю версию

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

Зависимости

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

jdbc

Simple DataSource implementation and DataSource wrapper with log capabilities.

DriverManagerDataSource

DataSource implementation which creates connections using DriverManager class. It makes no pooling. Creates new Connection instance each time when getConnection is called.

It is usefull for testing jdbc code which uses DataSource instance independently of environment which creates such instance.

Example of h2 DataSource instance creation

	DataSource ds = DriverManagerDataSource.instance(
			"org.h2.Driver"
			, "jdbc:h2:./target/databasefilename.h2;MODE=PostgreSQL"
			, "user"
			, "pass"
	);

LogDataSource

Wraps DataSource instance with some log capabilities. It logs

  • connection commits/rollbacks
  • statement executions
  • prepared statement executions with params
  • result set counts

Example of wrapping DataSource instance

	ds = LogDataSource.wrap(ds, 
			LogConfig.instance(
					() -> jdbclog.isDebugEnabled()
					, (message) -> jdbclog.debug(message))
		);

LogConfig

This class cumulates configuration of logging.

  • Consumer consumer - provides connection to logging real api
  • ConsumerStatus consumerStatus - provides connection to logging real api
  • boolean logStatement = true - enables loging of statement execution
  • boolean logResultSet = true - enables loging of result set counts (on close)
  • boolean logTransaction = true - enables loging of transaction boundaries

Log examples

connection boundary with connection identity 10

jdbc [10] commit time: 0

statement with connection identity 10 and statement identity 8

jdbc [10][8] statement: select vs, description from mytable where vs = '1111111111' time: 0

prepared statement with connection identity 10 and statement identity 9

jdbc [10][9] statement: update mytable set vs=?, description=? where vs = '1111111111' params:  ?1:1111111111 ?2:22222  result: 1 time: 1

result set with connection identity 10 and statement identity 8

jdbc [10][8] resultset row count: 2 first row time: 0 all row time: 2 close time: 0

Maven usage

   <dependency>
      <groupId>com.github.antonsjava</groupId>
      <artifactId>jdbc</artifactId>
      <version>1.0</version>
   </dependency>

Версии библиотеки

Версия
1.1
1.0